Initial commit

This commit is contained in:
Electroblob
2018-01-19 20:33:04 +00:00
commit da6b007a3a
945 changed files with 60616 additions and 0 deletions
@@ -0,0 +1,81 @@
package electroblob.wizardry.item;
import java.util.List;
import electroblob.wizardry.WizardData;
import electroblob.wizardry.registry.WizardryAchievements;
import electroblob.wizardry.registry.WizardryTabs;
import electroblob.wizardry.spell.Spell;
import electroblob.wizardry.util.WizardryUtilities;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class ItemIdentificationScroll extends Item {
public ItemIdentificationScroll() {
super();
this.setCreativeTab(WizardryTabs.WIZARDRY);
}
@Override
@SideOnly(Side.CLIENT)
public boolean hasEffect(ItemStack stack){
return true;
}
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean par4){
tooltip.add(net.minecraft.client.resources.I18n.format("item.wizardry:identification_scroll.desc1", "\u00A77"));
tooltip.add(net.minecraft.client.resources.I18n.format("item.wizardry:identification_scroll.desc2", "\u00A77"));
}
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand){
if(WizardData.get(player) != null){
WizardData properties = WizardData.get(player);
for(ItemStack stack1 : WizardryUtilities.getPrioritisedHotbarAndOffhand(player)){
if(stack1 != null){
Spell spell = Spell.get(stack1.getItemDamage());
if((stack1.getItem() instanceof ItemSpellBook || stack1.getItem() instanceof ItemScroll)
&& !properties.hasSpellBeenDiscovered(spell)){
// Identification scrolls give the chat readout in creative mode, otherwise it looks like
// nothing happens!
properties.discoverSpell(spell);
player.addStat(WizardryAchievements.identify_spell);
player.playSound(SoundEvents.ENTITY_PLAYER_LEVELUP, 1.25f, 1);
if(!player.capabilities.isCreativeMode) stack.stackSize--;
if(!world.isRemote) player.addChatMessage(new TextComponentTranslation("spell.discover", spell.getNameForTranslationFormatted()));
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
}
}
}
// If it found nothing to identify, it says so!
if(!world.isRemote) player.addChatMessage(new TextComponentTranslation("item.wizardry:identification_scroll.nothing_to_identify"));
}
return new ActionResult<ItemStack>(EnumActionResult.FAIL, stack);
}
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item parItem, CreativeTabs parTab, List<ItemStack> parListSubItems){
parListSubItems.add(new ItemStack(this, 1));
}
}