diff --git a/build.properties b/build.properties index 66a689ef..c56e8ba8 100644 --- a/build.properties +++ b/build.properties @@ -1,5 +1,5 @@ # #Sat Dec 28 00:14:08 EST 2013 minecraft_version = 1.7.10 -forge_version = 10.13.0.1180 +forge_version = 10.13.0.1182 mod_version = 0.2 diff --git a/src/main/java/com/pahimar/ee3/client/handler/ItemTooltipEventHandler.java b/src/main/java/com/pahimar/ee3/client/handler/ItemTooltipEventHandler.java index 40927271..1bc471f3 100644 --- a/src/main/java/com/pahimar/ee3/client/handler/ItemTooltipEventHandler.java +++ b/src/main/java/com/pahimar/ee3/client/handler/ItemTooltipEventHandler.java @@ -3,6 +3,8 @@ package com.pahimar.ee3.client.handler; import com.pahimar.ee3.api.EnergyValue; import com.pahimar.ee3.exchange.EnergyValueRegistry; import com.pahimar.ee3.exchange.WrappedStack; +import com.pahimar.ee3.item.IOwnable; +import com.pahimar.ee3.util.ItemHelper; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -48,5 +50,10 @@ public class ItemTooltipEventHandler event.toolTip.add("No Exchange Energy value"); } } + + if (event.itemStack.getItem() instanceof IOwnable) + { + event.toolTip.add("Owner: " + ItemHelper.getOwnerName(event.itemStack)); + } } } diff --git a/src/main/java/com/pahimar/ee3/handler/CraftingHandler.java b/src/main/java/com/pahimar/ee3/handler/CraftingHandler.java index a4f2b15f..dcf2eb3b 100644 --- a/src/main/java/com/pahimar/ee3/handler/CraftingHandler.java +++ b/src/main/java/com/pahimar/ee3/handler/CraftingHandler.java @@ -1,6 +1,8 @@ package com.pahimar.ee3.handler; +import com.pahimar.ee3.item.IOwnable; import com.pahimar.ee3.item.crafting.RecipesAlchemicalBagDyes; +import com.pahimar.ee3.util.ItemHelper; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.PlayerEvent; import net.minecraft.item.crafting.CraftingManager; @@ -16,6 +18,9 @@ public class CraftingHandler @SubscribeEvent public void onItemCraftedEvent(PlayerEvent.ItemCraftedEvent event) { - // TODO Set owner on who crafted the item (make sure it's not a FakePlayer) + if (event.crafting.getItem() instanceof IOwnable) + { + ItemHelper.setOwner(event.crafting, event.player); + } } } diff --git a/src/main/java/com/pahimar/ee3/init/Recipes.java b/src/main/java/com/pahimar/ee3/init/Recipes.java index 4c6ebfe8..5d7914f2 100644 --- a/src/main/java/com/pahimar/ee3/init/Recipes.java +++ b/src/main/java/com/pahimar/ee3/init/Recipes.java @@ -73,5 +73,13 @@ public class Recipes // Minium Stone RecipesAludel.getInstance().addRecipe(new ItemStack(ModItems.stoneMinium), new ItemStack(ModItems.stoneInert), new ItemStack(ModItems.alchemicalDust, 8, 3)); + + // Tome of Alchemical Knowledge + RecipesAludel.getInstance().addRecipe(new ItemStack(ModItems.alchemicalTome), new ItemStack(Items.book), new ItemStack(ModItems.alchemicalDust, 1, 3)); + + // Alchemical bags + RecipesAludel.getInstance().addRecipe(new ItemStack(ModItems.alchemicalBag, 1, 0), new ItemStack(Blocks.wool, 1, OreDictionary.WILDCARD_VALUE), new ItemStack(ModItems.alchemicalDust, 8, 1)); + RecipesAludel.getInstance().addRecipe(new ItemStack(ModItems.alchemicalBag, 1, 1), new ItemStack(Blocks.wool, 1, OreDictionary.WILDCARD_VALUE), new ItemStack(ModItems.alchemicalDust, 8, 2)); + RecipesAludel.getInstance().addRecipe(new ItemStack(ModItems.alchemicalBag, 1, 2), new ItemStack(Blocks.wool, 1, OreDictionary.WILDCARD_VALUE), new ItemStack(ModItems.alchemicalDust, 8, 3)); } } diff --git a/src/main/java/com/pahimar/ee3/inventory/SlotAlchemicalBag.java b/src/main/java/com/pahimar/ee3/inventory/SlotAlchemicalBag.java index 0362e53f..244e0797 100644 --- a/src/main/java/com/pahimar/ee3/inventory/SlotAlchemicalBag.java +++ b/src/main/java/com/pahimar/ee3/inventory/SlotAlchemicalBag.java @@ -11,9 +11,9 @@ public class SlotAlchemicalBag extends Slot private final EntityPlayer entityPlayer; private ContainerAlchemicalBag containerAlchemicalBag; - public SlotAlchemicalBag(ContainerAlchemicalBag containerAlchemicalBag, IInventory inventory, EntityPlayer entityPlayer, int x, int y, int z) + public SlotAlchemicalBag(ContainerAlchemicalBag containerAlchemicalBag, IInventory inventory, EntityPlayer entityPlayer, int slotIndex, int x, int y) { - super(inventory, x, y, z); + super(inventory, slotIndex, x, y); this.entityPlayer = entityPlayer; this.containerAlchemicalBag = containerAlchemicalBag; } diff --git a/src/main/java/com/pahimar/ee3/inventory/SlotAludelOutput.java b/src/main/java/com/pahimar/ee3/inventory/SlotAludelOutput.java index 80b76230..b4571d76 100644 --- a/src/main/java/com/pahimar/ee3/inventory/SlotAludelOutput.java +++ b/src/main/java/com/pahimar/ee3/inventory/SlotAludelOutput.java @@ -8,9 +8,9 @@ import net.minecraft.item.ItemStack; public class SlotAludelOutput extends Slot { - public SlotAludelOutput(IInventory inventory, int x, int y, int z) + public SlotAludelOutput(IInventory inventory, int slotIndex, int x, int y) { - super(inventory, x, y, z); + super(inventory, slotIndex, x, y); } @Override diff --git a/src/main/java/com/pahimar/ee3/inventory/SlotCalcinator.java b/src/main/java/com/pahimar/ee3/inventory/SlotCalcinator.java index a7dcaca7..85b010c1 100644 --- a/src/main/java/com/pahimar/ee3/inventory/SlotCalcinator.java +++ b/src/main/java/com/pahimar/ee3/inventory/SlotCalcinator.java @@ -8,9 +8,9 @@ import net.minecraft.item.ItemStack; public class SlotCalcinator extends Slot { - public SlotCalcinator(IInventory inventory, int x, int y, int z) + public SlotCalcinator(IInventory inventory, int slotIndex, int x, int y) { - super(inventory, x, y, z); + super(inventory, slotIndex, x, y); } @Override diff --git a/src/main/java/com/pahimar/ee3/inventory/SlotResearchStation.java b/src/main/java/com/pahimar/ee3/inventory/SlotResearchStation.java new file mode 100644 index 00000000..2baa319c --- /dev/null +++ b/src/main/java/com/pahimar/ee3/inventory/SlotResearchStation.java @@ -0,0 +1,12 @@ +package com.pahimar.ee3.inventory; + +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; + +public class SlotResearchStation extends Slot +{ + public SlotResearchStation(IInventory inventory, int slotIndex, int x, int y) + { + super(inventory, slotIndex, x, y); + } +} diff --git a/src/main/java/com/pahimar/ee3/item/IOwnable.java b/src/main/java/com/pahimar/ee3/item/IOwnable.java new file mode 100644 index 00000000..a9d9f1c1 --- /dev/null +++ b/src/main/java/com/pahimar/ee3/item/IOwnable.java @@ -0,0 +1,6 @@ +package com.pahimar.ee3.item; + +public interface IOwnable +{ + +} diff --git a/src/main/java/com/pahimar/ee3/item/ItemAlchemicalBag.java b/src/main/java/com/pahimar/ee3/item/ItemAlchemicalBag.java index 8046fc0c..cda73f57 100644 --- a/src/main/java/com/pahimar/ee3/item/ItemAlchemicalBag.java +++ b/src/main/java/com/pahimar/ee3/item/ItemAlchemicalBag.java @@ -6,6 +6,7 @@ import com.pahimar.ee3.reference.GuiIds; import com.pahimar.ee3.reference.Names; import com.pahimar.ee3.reference.Textures; import com.pahimar.ee3.util.ColorHelper; +import com.pahimar.ee3.util.ItemHelper; import com.pahimar.ee3.util.NBTHelper; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -21,7 +22,7 @@ import net.minecraft.world.World; import java.util.List; -public class ItemAlchemicalBag extends ItemEE +public class ItemAlchemicalBag extends ItemEE implements IOwnable { private static final String[] ALCHEMICAL_BAG_ICONS = {"open", "closed", "symbolTier1", "symbolTier2", "symbolTier3"}; @@ -95,6 +96,9 @@ public class ItemAlchemicalBag extends ItemEE { if (!world.isRemote) { + // Set the owner + ItemHelper.setOwner(itemStack, entityPlayer); + // Set a UUID on the Alchemical Bag, if one doesn't exist already NBTHelper.setUUID(itemStack); NBTHelper.setBoolean(itemStack, Names.NBT.ALCHEMICAL_BAG_GUI_OPEN, true); diff --git a/src/main/java/com/pahimar/ee3/item/ItemAlchemicalTome.java b/src/main/java/com/pahimar/ee3/item/ItemAlchemicalTome.java index e6ada60a..f027a9b9 100644 --- a/src/main/java/com/pahimar/ee3/item/ItemAlchemicalTome.java +++ b/src/main/java/com/pahimar/ee3/item/ItemAlchemicalTome.java @@ -2,7 +2,7 @@ package com.pahimar.ee3.item; import com.pahimar.ee3.reference.Names; -public class ItemAlchemicalTome extends ItemEE +public class ItemAlchemicalTome extends ItemEE implements IOwnable { public ItemAlchemicalTome() { diff --git a/src/main/java/com/pahimar/ee3/item/ItemMatterPickAxe.java b/src/main/java/com/pahimar/ee3/item/ItemMatterPickAxe.java index 34e732b4..9e648759 100644 --- a/src/main/java/com/pahimar/ee3/item/ItemMatterPickAxe.java +++ b/src/main/java/com/pahimar/ee3/item/ItemMatterPickAxe.java @@ -11,16 +11,18 @@ import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; import net.minecraft.item.ItemPickaxe; import net.minecraft.item.ItemStack; +import net.minecraftforge.common.ForgeHooks; public class ItemMatterPickAxe extends ItemPickaxe implements IKeyBound, IChargeable { private short maxChargeLevel; - public ItemMatterPickAxe(ToolMaterial toolMaterial1, int maxChargeLevel) + public ItemMatterPickAxe(ToolMaterial toolMaterial, int maxChargeLevel) { - super(toolMaterial1); + super(toolMaterial); this.maxChargeLevel = (short) maxChargeLevel; this.setCreativeTab(CreativeTab.EE3_TAB); this.setNoRepair(); @@ -77,7 +79,7 @@ public class ItemMatterPickAxe extends ItemPickaxe implements IKeyBound, ICharge @Override public float getDigSpeed(ItemStack itemStack, Block block, int meta) { - if (itemStack.getItem() instanceof IChargeable) + if ((ForgeHooks.isToolEffective(itemStack, block, meta) || block == Blocks.obsidian || block == Blocks.redstone_ore || block == Blocks.lit_redstone_ore) && (itemStack.getItem() instanceof IChargeable)) { return super.getDigSpeed(itemStack, block, meta) + (((IChargeable) itemStack.getItem()).getChargeLevel(itemStack) * 12f); } diff --git a/src/main/java/com/pahimar/ee3/proxy/CommonProxy.java b/src/main/java/com/pahimar/ee3/proxy/CommonProxy.java index b7d3fad1..a0df1473 100644 --- a/src/main/java/com/pahimar/ee3/proxy/CommonProxy.java +++ b/src/main/java/com/pahimar/ee3/proxy/CommonProxy.java @@ -1,5 +1,6 @@ package com.pahimar.ee3.proxy; +import com.pahimar.ee3.handler.CraftingHandler; import com.pahimar.ee3.handler.ItemEventHandler; import com.pahimar.ee3.handler.PlayerEventHandler; import com.pahimar.ee3.handler.WorldEventHandler; @@ -14,11 +15,14 @@ public abstract class CommonProxy implements IProxy public void registerEventHandlers() { ItemEventHandler itemEventHandler = new ItemEventHandler(); + CraftingHandler craftingHandler = new CraftingHandler(); FMLCommonHandler.instance().bus().register(itemEventHandler); MinecraftForge.EVENT_BUS.register(itemEventHandler); MinecraftForge.EVENT_BUS.register(new WorldEventHandler()); MinecraftForge.EVENT_BUS.register(new PlayerEventHandler()); + FMLCommonHandler.instance().bus().register(craftingHandler); + MinecraftForge.EVENT_BUS.register(craftingHandler); } public void registerTileEntities() diff --git a/src/main/java/com/pahimar/ee3/reference/Messages.java b/src/main/java/com/pahimar/ee3/reference/Messages.java index ad72228b..2c85066f 100644 --- a/src/main/java/com/pahimar/ee3/reference/Messages.java +++ b/src/main/java/com/pahimar/ee3/reference/Messages.java @@ -3,6 +3,7 @@ package com.pahimar.ee3.reference; public class Messages { public static final String UPGRADES_CHESTS = "tooltip.ee3:upgradesPrefix"; + public static final String NO_OWNER = "tooltip.ee3:none"; /* Fingerprint check related constants */ public static final String NO_FINGERPRINT_MESSAGE = "The copy of Equivalent Exchange 3 that you are running is a development version of the mod, and as such may be unstable and/or incomplete."; diff --git a/src/main/java/com/pahimar/ee3/reference/Names.java b/src/main/java/com/pahimar/ee3/reference/Names.java index 2f397a2b..38a56766 100644 --- a/src/main/java/com/pahimar/ee3/reference/Names.java +++ b/src/main/java/com/pahimar/ee3/reference/Names.java @@ -74,6 +74,8 @@ public class Names public static final String CUSTOM_NAME = "CustomName"; public static final String DIRECTION = "teDirection"; public static final String OWNER = "owner"; + public static final String OWNER_UUID_MOST_SIG = "ownerUUIDMostSig"; + public static final String OWNER_UUID_LEAST_SIG = "ownerUUIDLeastSig"; } public static final class Containers diff --git a/src/main/java/com/pahimar/ee3/util/EntityPlayerHelper.java b/src/main/java/com/pahimar/ee3/util/EntityPlayerHelper.java new file mode 100644 index 00000000..023cf078 --- /dev/null +++ b/src/main/java/com/pahimar/ee3/util/EntityPlayerHelper.java @@ -0,0 +1,42 @@ +package com.pahimar.ee3.util; + +import cpw.mods.fml.common.FMLCommonHandler; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraftforge.common.util.FakePlayer; + +public class EntityPlayerHelper +{ + public static boolean isFakePlayer(EntityPlayer entityPlayer) + { + if (entityPlayer instanceof FakePlayer) + { + return true; + } + else if (entityPlayer.getGameProfile() == null || entityPlayer.getGameProfile().getId() == null) + { + return true; + } + else if (entityPlayer instanceof EntityPlayerMP) + { + EntityPlayerMP entityPlayerMP = (EntityPlayerMP) entityPlayer; + if (entityPlayerMP.playerNetServerHandler == null) + { + return true; + } + + try + { + entityPlayerMP.getPlayerIP(); + } + catch (Exception e) + { + return true; + } + + return !FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().playerEntityList.contains(entityPlayer); + } + + return false; + } +} diff --git a/src/main/java/com/pahimar/ee3/util/ItemHelper.java b/src/main/java/com/pahimar/ee3/util/ItemHelper.java index f4a1228f..605d8007 100644 --- a/src/main/java/com/pahimar/ee3/util/ItemHelper.java +++ b/src/main/java/com/pahimar/ee3/util/ItemHelper.java @@ -1,9 +1,14 @@ package com.pahimar.ee3.util; +import com.pahimar.ee3.reference.Messages; +import com.pahimar.ee3.reference.Names; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.util.StatCollector; import java.util.Comparator; +import java.util.UUID; public class ItemHelper { @@ -97,4 +102,36 @@ public class ItemHelper return "null"; } + + public static boolean hasOwner(ItemStack itemStack) + { + return (NBTHelper.hasTag(itemStack, Names.NBT.OWNER_UUID_MOST_SIG) && NBTHelper.hasTag(itemStack, Names.NBT.OWNER_UUID_LEAST_SIG)) || NBTHelper.hasTag(itemStack, Names.NBT.OWNER); + } + + public static String getOwnerName(ItemStack itemStack) + { + if (NBTHelper.hasTag(itemStack, Names.NBT.OWNER)) + { + return NBTHelper.getString(itemStack, Names.NBT.OWNER); + } + + return StatCollector.translateToLocal(Messages.NO_OWNER); + } + + public static UUID getOwnerUUID(ItemStack itemStack) + { + if (NBTHelper.hasTag(itemStack, Names.NBT.OWNER_UUID_MOST_SIG) && NBTHelper.hasTag(itemStack, Names.NBT.OWNER_UUID_LEAST_SIG)) + { + return new UUID(NBTHelper.getLong(itemStack, Names.NBT.OWNER_UUID_MOST_SIG), NBTHelper.getLong(itemStack, Names.NBT.OWNER_UUID_LEAST_SIG)); + } + + return null; + } + + public static void setOwner(ItemStack itemStack, EntityPlayer entityPlayer) + { + NBTHelper.setString(itemStack, Names.NBT.OWNER, entityPlayer.getDisplayName()); + NBTHelper.setLong(itemStack, Names.NBT.OWNER_UUID_MOST_SIG, entityPlayer.getUniqueID().getMostSignificantBits()); + NBTHelper.setLong(itemStack, Names.NBT.OWNER_UUID_LEAST_SIG, entityPlayer.getUniqueID().getLeastSignificantBits()); + } } diff --git a/src/main/resources/assets/ee3/lang/en_US.lang b/src/main/resources/assets/ee3/lang/en_US.lang index e3204885..3c95f5e1 100644 --- a/src/main/resources/assets/ee3/lang/en_US.lang +++ b/src/main/resources/assets/ee3/lang/en_US.lang @@ -87,6 +87,7 @@ tooltip.ee3:upgradesPrefix=Upgrades (Alchemical) Chests tooltip.ee3:alchemicalChestPrefix.small=Small tooltip.ee3:alchemicalChestPrefix.medium=Medium tooltip.ee3:alchemicalChestPrefix.large=Large +tooltip.ee3:none=None # Creative Tabs itemGroup.ee3=Equivalent Exchange 3