Started on Tool Table tools, noticed how I was doing stupidly much for the tooltip event that I didn't need to do, probably more stuff that I can't remember

This commit is contained in:
Ellpeck 2015-09-23 21:34:12 +02:00
parent 7145c273f1
commit 835e8734ab
17 changed files with 407 additions and 75 deletions

View file

@ -29,6 +29,7 @@ import ellpeck.actuallyadditions.inventory.GuiHandler;
import ellpeck.actuallyadditions.items.InitForeignPaxels; import ellpeck.actuallyadditions.items.InitForeignPaxels;
import ellpeck.actuallyadditions.items.InitItems; import ellpeck.actuallyadditions.items.InitItems;
import ellpeck.actuallyadditions.items.ItemCoffee; import ellpeck.actuallyadditions.items.ItemCoffee;
import ellpeck.actuallyadditions.items.tools.table.InitToolTableTools;
import ellpeck.actuallyadditions.material.InitArmorMaterials; import ellpeck.actuallyadditions.material.InitArmorMaterials;
import ellpeck.actuallyadditions.material.InitToolMaterials; import ellpeck.actuallyadditions.material.InitToolMaterials;
import ellpeck.actuallyadditions.misc.DispenserHandlerEmptyBucket; import ellpeck.actuallyadditions.misc.DispenserHandlerEmptyBucket;
@ -38,7 +39,6 @@ import ellpeck.actuallyadditions.ore.InitOreDict;
import ellpeck.actuallyadditions.proxy.IProxy; import ellpeck.actuallyadditions.proxy.IProxy;
import ellpeck.actuallyadditions.recipe.FuelHandler; import ellpeck.actuallyadditions.recipe.FuelHandler;
import ellpeck.actuallyadditions.recipe.HairyBallHandler; import ellpeck.actuallyadditions.recipe.HairyBallHandler;
import ellpeck.actuallyadditions.recipe.ToolTableHandler;
import ellpeck.actuallyadditions.recipe.TreasureChestHandler; import ellpeck.actuallyadditions.recipe.TreasureChestHandler;
import ellpeck.actuallyadditions.tile.TileEntityBase; import ellpeck.actuallyadditions.tile.TileEntityBase;
import ellpeck.actuallyadditions.update.UpdateChecker; import ellpeck.actuallyadditions.update.UpdateChecker;
@ -97,9 +97,9 @@ public class ActuallyAdditions{
CrusherCrafting.init(); CrusherCrafting.init();
ItemCrafting.initMashedFoodRecipes(); ItemCrafting.initMashedFoodRecipes();
HairyBallHandler.init(); HairyBallHandler.init();
ToolTableHandler.init();
TreasureChestHandler.init(); TreasureChestHandler.init();
InitForeignPaxels.init(); InitForeignPaxels.init();
InitToolTableTools.init();
proxy.postInit(event); proxy.postInit(event);
ModUtil.LOGGER.info("PostInitialization Finished."); ModUtil.LOGGER.info("PostInitialization Finished.");

View file

@ -11,7 +11,6 @@
package ellpeck.actuallyadditions.event; package ellpeck.actuallyadditions.event;
import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.relauncher.ReflectionHelper;
import ellpeck.actuallyadditions.booklet.GuiBooklet; import ellpeck.actuallyadditions.booklet.GuiBooklet;
import ellpeck.actuallyadditions.booklet.InitBooklet; import ellpeck.actuallyadditions.booklet.InitBooklet;
import ellpeck.actuallyadditions.booklet.page.BookletPage; import ellpeck.actuallyadditions.booklet.page.BookletPage;
@ -20,17 +19,12 @@ import ellpeck.actuallyadditions.items.InitItems;
import ellpeck.actuallyadditions.util.*; import ellpeck.actuallyadditions.util.*;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.PositionedSoundRecord; import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.event.entity.player.ItemTooltipEvent; import net.minecraftforge.event.entity.player.ItemTooltipEvent;
import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.OreDictionary;
import org.lwjgl.input.Keyboard; import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
public class TooltipEvent{ public class TooltipEvent{
@ -41,23 +35,9 @@ public class TooltipEvent{
@SubscribeEvent @SubscribeEvent
public void onTooltipEvent(ItemTooltipEvent event){ public void onTooltipEvent(ItemTooltipEvent event){
//Booklet Access //Booklet Access
GuiScreen screen = Minecraft.getMinecraft().currentScreen; if(event.itemStack != null && !(Minecraft.getMinecraft().currentScreen instanceof GuiBooklet)){
if(screen != null && !(screen instanceof GuiBooklet) && screen instanceof GuiContainer){
GuiContainer gui = (GuiContainer)screen;
if(gui.inventorySlots != null && gui.inventorySlots.inventorySlots != null && !gui.inventorySlots.inventorySlots.isEmpty()){
for(int i = 0; i < gui.inventorySlots.inventorySlots.size(); i++){
Slot slot = gui.inventorySlots.getSlot(i);
int guiLeft = ReflectionHelper.getPrivateValue(GuiContainer.class, gui, 4);
int guiTop = ReflectionHelper.getPrivateValue(GuiContainer.class, gui, 5);
int mouseX = Mouse.getEventX()*gui.width/Minecraft.getMinecraft().displayWidth-guiLeft;
int mouseY = gui.height-Mouse.getEventY()*gui.height/Minecraft.getMinecraft().displayHeight-1-guiTop;
if(mouseX >= slot.xDisplayPosition-1 && mouseY >= slot.yDisplayPosition-1 && mouseX <= slot.xDisplayPosition+16 && mouseY <= slot.yDisplayPosition+16){
ItemStack stack = slot.getStack();
if(stack != null){
for(BookletPage page : InitBooklet.pagesWithItemStackData){ for(BookletPage page : InitBooklet.pagesWithItemStackData){
if(ItemUtil.areItemsEqual(stack, page.getItemStackForPage(), true)){ if(ItemUtil.areItemsEqual(event.itemStack, page.getItemStackForPage(), true)){
int keyCode = KeyBinds.keybindOpenBooklet.getKeyCode(); int keyCode = KeyBinds.keybindOpenBooklet.getKeyCode();
if(!ConfigBoolValues.NEED_BOOKLET_FOR_KEYBIND_INFO.isEnabled() || Minecraft.getMinecraft().thePlayer.inventory.hasItem(InitItems.itemLexicon)){ if(!ConfigBoolValues.NEED_BOOKLET_FOR_KEYBIND_INFO.isEnabled() || Minecraft.getMinecraft().thePlayer.inventory.hasItem(InitItems.itemLexicon)){
if(ConfigBoolValues.SHOW_NEED_BOOKLET_FOR_KEYBIND_INFO.isEnabled()){ if(ConfigBoolValues.SHOW_NEED_BOOKLET_FOR_KEYBIND_INFO.isEnabled()){
@ -80,10 +60,6 @@ public class TooltipEvent{
} }
} }
} }
}
}
}
}
//Advanced Item Info //Advanced Item Info
if(event.itemStack.getItem() != null){ if(event.itemStack.getItem() != null){

View file

@ -24,7 +24,7 @@ public class ItemBattery extends ItemEnergy implements INameableItem{
private String name; private String name;
public ItemBattery(String name, int capacity, int transfer){ public ItemBattery(String name, int capacity, int transfer){
super(capacity, transfer, 1); super(capacity, transfer);
this.setMaxStackSize(1); this.setMaxStackSize(1);
this.name = name; this.name = name;
} }

View file

@ -20,6 +20,7 @@ import ellpeck.actuallyadditions.config.values.ConfigFloatValues;
import ellpeck.actuallyadditions.config.values.ConfigIntValues; import ellpeck.actuallyadditions.config.values.ConfigIntValues;
import ellpeck.actuallyadditions.inventory.GuiHandler; import ellpeck.actuallyadditions.inventory.GuiHandler;
import ellpeck.actuallyadditions.util.INameableItem; import ellpeck.actuallyadditions.util.INameableItem;
import ellpeck.actuallyadditions.util.ItemUtil;
import ellpeck.actuallyadditions.util.ModUtil; import ellpeck.actuallyadditions.util.ModUtil;
import ellpeck.actuallyadditions.util.WorldUtil; import ellpeck.actuallyadditions.util.WorldUtil;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@ -49,7 +50,7 @@ import java.util.Set;
public class ItemDrill extends ItemEnergy implements INameableItem{ public class ItemDrill extends ItemEnergy implements INameableItem{
public ItemDrill(){ public ItemDrill(){
super(500000, 5000, 4); super(500000, 5000);
} }
@Override @Override
@ -379,15 +380,8 @@ public class ItemDrill extends ItemEnergy implements INameableItem{
else toReturn = this.breakBlocks(stack, 0, player.worldObj, x, y, z, player); else toReturn = this.breakBlocks(stack, 0, player.worldObj, x, y, z, player);
//Removes Enchantments added above //Removes Enchantments added above
NBTTagList ench = stack.getEnchantmentTagList(); ItemUtil.removeEnchantment(stack, Enchantment.silkTouch);
if(ench != null){ ItemUtil.removeEnchantment(stack, Enchantment.fortune);
for(int i = 0; i < ench.tagCount(); i++){
short id = ench.getCompoundTagAt(i).getShort("id");
if(id == Enchantment.silkTouch.effectId || id == Enchantment.fortune.effectId){
ench.removeTag(i);
}
}
}
} }
return toReturn; return toReturn;
} }

View file

@ -24,13 +24,10 @@ import java.util.List;
public abstract class ItemEnergy extends ItemEnergyContainer{ public abstract class ItemEnergy extends ItemEnergyContainer{
private int infoLines; public ItemEnergy(int maxPower, int transfer){
public ItemEnergy(int maxPower, int transfer, int infoLines){
super(maxPower, transfer); super(maxPower, transfer);
this.setHasSubtypes(true); this.setHasSubtypes(true);
this.setMaxStackSize(1); this.setMaxStackSize(1);
this.infoLines = infoLines;
} }
@Override @Override

View file

@ -36,7 +36,7 @@ import java.util.Random;
public class ItemGrowthRing extends ItemEnergy implements INameableItem{ public class ItemGrowthRing extends ItemEnergy implements INameableItem{
public ItemGrowthRing(){ public ItemGrowthRing(){
super(1000000, 5000, 1); super(1000000, 5000);
} }
@Override @Override

View file

@ -31,7 +31,7 @@ import java.util.ArrayList;
public class ItemMagnetRing extends ItemEnergy implements INameableItem{ public class ItemMagnetRing extends ItemEnergy implements INameableItem{
public ItemMagnetRing(){ public ItemMagnetRing(){
super(3000000, 5000, 1); super(3000000, 5000);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")

View file

@ -32,7 +32,7 @@ import net.minecraftforge.common.util.ForgeDirection;
public class ItemTeleStaff extends ItemEnergy implements INameableItem{ public class ItemTeleStaff extends ItemEnergy implements INameableItem{
public ItemTeleStaff(){ public ItemTeleStaff(){
super(500000, 10000, 2); super(500000, 10000);
} }
@Override @Override

View file

@ -28,7 +28,7 @@ import net.minecraft.world.World;
public class ItemWaterRemovalRing extends ItemEnergy implements INameableItem{ public class ItemWaterRemovalRing extends ItemEnergy implements INameableItem{
public ItemWaterRemovalRing(){ public ItemWaterRemovalRing(){
super(1000000, 5000, 1); super(1000000, 5000);
} }
@Override @Override

View file

@ -0,0 +1,31 @@
/*
* This file ("InitToolTableTools.java") is part of the Actually Additions Mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015 Ellpeck
*/
package ellpeck.actuallyadditions.items.tools.table;
import ellpeck.actuallyadditions.items.tools.table.ItemPickaxeFixedEnchants.EnchantmentCombo;
import ellpeck.actuallyadditions.util.ItemUtil;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item;
public class InitToolTableTools{
public static Item itemMinersPickaxe;
public static Item itemSilkyMinersPickaxe;
public static void init(){
itemMinersPickaxe = new ItemPickaxeFixedEnchants(Item.ToolMaterial.EMERALD, "itemMinersPickaxe", EnumRarity.rare, new EnchantmentCombo(Enchantment.fortune, 2), new EnchantmentCombo(Enchantment.efficiency, 2), new EnchantmentCombo(Enchantment.unbreaking, 1));
ItemUtil.register(itemMinersPickaxe);
itemSilkyMinersPickaxe = new ItemPickaxeFixedEnchants(Item.ToolMaterial.EMERALD, "itemSilkyMinersPickaxe", EnumRarity.rare, new EnchantmentCombo(Enchantment.silkTouch, 1), new EnchantmentCombo(Enchantment.efficiency, 2), new EnchantmentCombo(Enchantment.unbreaking, 1));
ItemUtil.register(itemSilkyMinersPickaxe);
}
}

View file

@ -0,0 +1,82 @@
/*
* This file ("ItemAxeFixedEnchants.java") is part of the Actually Additions Mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015 Ellpeck
*/
package ellpeck.actuallyadditions.items.tools.table;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.items.tools.ItemAxeAA;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import java.util.List;
public class ItemAxeFixedEnchants extends ItemAxeAA{
public static class EnchantmentCombo{
public Enchantment enchantment;
public int level;
public EnchantmentCombo(Enchantment ench, int level){
this.enchantment = ench;
this.level = level;
}
}
private EnchantmentCombo[] enchantments;
public ItemAxeFixedEnchants(ToolMaterial toolMat, String unlocalizedName, EnumRarity rarity, EnchantmentCombo... enchantments){
super(toolMat, "", unlocalizedName, rarity);
this.enchantments = enchantments;
}
@Override
public boolean hasEffect(ItemStack stack, int pass){
return false;
}
@Override
public boolean isRepairable(){
return false;
}
@Override
public boolean getIsRepairable(ItemStack stack1, ItemStack stack2){
return this.isRepairable();
}
@Override
public int getItemEnchantability(ItemStack stack){
return 0;
}
@Override
public void onCreated(ItemStack stack, World world, EntityPlayer player){
for(EnchantmentCombo combo : this.enchantments){
stack.addEnchantment(combo.enchantment, combo.level);
}
}
@SuppressWarnings("unchecked")
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs tab, List list){
ItemStack stack = new ItemStack(item);
for(EnchantmentCombo combo : this.enchantments){
stack.addEnchantment(combo.enchantment, combo.level);
}
list.add(stack);
}
}

View file

@ -0,0 +1,82 @@
/*
* This file ("ItemPickaxeNoEnchants.java") is part of the Actually Additions Mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015 Ellpeck
*/
package ellpeck.actuallyadditions.items.tools.table;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.items.tools.ItemPickaxeAA;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import java.util.List;
public class ItemPickaxeFixedEnchants extends ItemPickaxeAA{
public static class EnchantmentCombo{
public Enchantment enchantment;
public int level;
public EnchantmentCombo(Enchantment ench, int level){
this.enchantment = ench;
this.level = level;
}
}
private EnchantmentCombo[] enchantments;
public ItemPickaxeFixedEnchants(ToolMaterial toolMat, String unlocalizedName, EnumRarity rarity, EnchantmentCombo... enchantments){
super(toolMat, "", unlocalizedName, rarity);
this.enchantments = enchantments;
}
@Override
public boolean hasEffect(ItemStack stack, int pass){
return false;
}
@Override
public boolean isRepairable(){
return false;
}
@Override
public boolean getIsRepairable(ItemStack stack1, ItemStack stack2){
return this.isRepairable();
}
@Override
public int getItemEnchantability(ItemStack stack){
return 0;
}
@Override
public void onCreated(ItemStack stack, World world, EntityPlayer player){
for(EnchantmentCombo combo : this.enchantments){
stack.addEnchantment(combo.enchantment, combo.level);
}
}
@SuppressWarnings("unchecked")
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs tab, List list){
ItemStack stack = new ItemStack(item);
for(EnchantmentCombo combo : this.enchantments){
stack.addEnchantment(combo.enchantment, combo.level);
}
list.add(stack);
}
}

View file

@ -0,0 +1,82 @@
/*
* This file ("ItemShovelFixedEnchants.java") is part of the Actually Additions Mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015 Ellpeck
*/
package ellpeck.actuallyadditions.items.tools.table;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.items.tools.ItemShovelAA;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import java.util.List;
public class ItemShovelFixedEnchants extends ItemShovelAA{
public static class EnchantmentCombo{
public Enchantment enchantment;
public int level;
public EnchantmentCombo(Enchantment ench, int level){
this.enchantment = ench;
this.level = level;
}
}
private EnchantmentCombo[] enchantments;
public ItemShovelFixedEnchants(ToolMaterial toolMat, String unlocalizedName, EnumRarity rarity, EnchantmentCombo... enchantments){
super(toolMat, "", unlocalizedName, rarity);
this.enchantments = enchantments;
}
@Override
public boolean hasEffect(ItemStack stack, int pass){
return false;
}
@Override
public boolean isRepairable(){
return false;
}
@Override
public boolean getIsRepairable(ItemStack stack1, ItemStack stack2){
return this.isRepairable();
}
@Override
public int getItemEnchantability(ItemStack stack){
return 0;
}
@Override
public void onCreated(ItemStack stack, World world, EntityPlayer player){
for(EnchantmentCombo combo : this.enchantments){
stack.addEnchantment(combo.enchantment, combo.level);
}
}
@SuppressWarnings("unchecked")
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs tab, List list){
ItemStack stack = new ItemStack(item);
for(EnchantmentCombo combo : this.enchantments){
stack.addEnchantment(combo.enchantment, combo.level);
}
list.add(stack);
}
}

View file

@ -0,0 +1,82 @@
/*
* This file ("ItemSwordFixedEnchants.java") is part of the Actually Additions Mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015 Ellpeck
*/
package ellpeck.actuallyadditions.items.tools.table;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.items.tools.ItemSwordAA;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import java.util.List;
public class ItemSwordFixedEnchants extends ItemSwordAA{
public static class EnchantmentCombo{
public Enchantment enchantment;
public int level;
public EnchantmentCombo(Enchantment ench, int level){
this.enchantment = ench;
this.level = level;
}
}
private EnchantmentCombo[] enchantments;
public ItemSwordFixedEnchants(ToolMaterial toolMat, String unlocalizedName, EnumRarity rarity, EnchantmentCombo... enchantments){
super(toolMat, "", unlocalizedName, rarity);
this.enchantments = enchantments;
}
@Override
public boolean hasEffect(ItemStack stack, int pass){
return false;
}
@Override
public boolean isRepairable(){
return false;
}
@Override
public boolean getIsRepairable(ItemStack stack1, ItemStack stack2){
return this.isRepairable();
}
@Override
public int getItemEnchantability(ItemStack stack){
return 0;
}
@Override
public void onCreated(ItemStack stack, World world, EntityPlayer player){
for(EnchantmentCombo combo : this.enchantments){
stack.addEnchantment(combo.enchantment, combo.level);
}
}
@SuppressWarnings("unchecked")
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs tab, List list){
ItemStack stack = new ItemStack(item);
for(EnchantmentCombo combo : this.enchantments){
stack.addEnchantment(combo.enchantment, combo.level);
}
list.add(stack);
}
}

View file

@ -10,10 +10,7 @@
package ellpeck.actuallyadditions.recipe; package ellpeck.actuallyadditions.recipe;
import ellpeck.actuallyadditions.items.InitItems;
import ellpeck.actuallyadditions.util.ItemUtil; import ellpeck.actuallyadditions.util.ItemUtil;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import java.util.ArrayList; import java.util.ArrayList;
@ -22,12 +19,7 @@ public class ToolTableHandler{
public static ArrayList<Recipe> recipes = new ArrayList<Recipe>(); public static ArrayList<Recipe> recipes = new ArrayList<Recipe>();
public static void init(){ public static void addRecipe(ItemStack output, ItemStack... itemsNeeded){
//TODO Actual real recipes
addRecipe(new ItemStack(InitItems.itemPhantomConnector), new ItemStack(Items.diamond_pickaxe), new ItemStack(Blocks.stone_brick_stairs), new ItemStack(Blocks.planks));
}
private static void addRecipe(ItemStack output, ItemStack... itemsNeeded){
recipes.add(new Recipe(output, itemsNeeded)); recipes.add(new Recipe(output, itemsNeeded));
} }

View file

@ -12,8 +12,10 @@ package ellpeck.actuallyadditions.util;
import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.GameRegistry;
import ellpeck.actuallyadditions.creative.CreativeTab; import ellpeck.actuallyadditions.creative.CreativeTab;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagList;
public class ItemUtil{ public class ItemUtil{
@ -78,4 +80,16 @@ public class ItemUtil{
public static boolean areItemsEqual(ItemStack stack1, ItemStack stack2, boolean checkWildcard){ public static boolean areItemsEqual(ItemStack stack1, ItemStack stack2, boolean checkWildcard){
return stack1 != null && stack2 != null && (stack1.isItemEqual(stack2) || (checkWildcard && stack1.getItem() == stack2.getItem() && (stack1.getItemDamage() == Util.WILDCARD || stack2.getItemDamage() == Util.WILDCARD))); return stack1 != null && stack2 != null && (stack1.isItemEqual(stack2) || (checkWildcard && stack1.getItem() == stack2.getItem() && (stack1.getItemDamage() == Util.WILDCARD || stack2.getItemDamage() == Util.WILDCARD)));
} }
public static void removeEnchantment(ItemStack stack, Enchantment e){
NBTTagList ench = stack.getEnchantmentTagList();
if(ench != null){
for(int i = 0; i < ench.tagCount(); i++){
short id = ench.getCompoundTagAt(i).getShort("id");
if(id == e.effectId){
ench.removeTag(i);
}
}
}
}
} }

View file

@ -299,7 +299,7 @@ public class WorldUtil{
Block block = world.getBlock(xPos, yPos, zPos); Block block = world.getBlock(xPos, yPos, zPos);
int meta = world.getBlockMetadata(xPos, yPos, zPos); int meta = world.getBlockMetadata(xPos, yPos, zPos);
//If the Block can be harvested or not //If the Block can be harvested or not
boolean canHarvest = block.canHarvestBlock(player, meta) && player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem().canHarvestBlock(block, player.getCurrentEquippedItem()); boolean canHarvest = block.canHarvestBlock(player, meta);
if(!world.isRemote){ if(!world.isRemote){
//Server-Side only, special cases //Server-Side only, special cases