Commiting a chunk of code

This commit is contained in:
Pahimar 2014-07-15 12:24:18 -04:00
parent a7a13d05a3
commit 85e1a62c5a
18 changed files with 144 additions and 13 deletions

View file

@ -1,5 +1,5 @@
# #
#Sat Dec 28 00:14:08 EST 2013 #Sat Dec 28 00:14:08 EST 2013
minecraft_version = 1.7.10 minecraft_version = 1.7.10
forge_version = 10.13.0.1180 forge_version = 10.13.0.1182
mod_version = 0.2 mod_version = 0.2

View file

@ -3,6 +3,8 @@ package com.pahimar.ee3.client.handler;
import com.pahimar.ee3.api.EnergyValue; import com.pahimar.ee3.api.EnergyValue;
import com.pahimar.ee3.exchange.EnergyValueRegistry; import com.pahimar.ee3.exchange.EnergyValueRegistry;
import com.pahimar.ee3.exchange.WrappedStack; 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.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
@ -48,5 +50,10 @@ public class ItemTooltipEventHandler
event.toolTip.add("No Exchange Energy value"); event.toolTip.add("No Exchange Energy value");
} }
} }
if (event.itemStack.getItem() instanceof IOwnable)
{
event.toolTip.add("Owner: " + ItemHelper.getOwnerName(event.itemStack));
}
} }
} }

View file

@ -1,6 +1,8 @@
package com.pahimar.ee3.handler; package com.pahimar.ee3.handler;
import com.pahimar.ee3.item.IOwnable;
import com.pahimar.ee3.item.crafting.RecipesAlchemicalBagDyes; 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.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent; import cpw.mods.fml.common.gameevent.PlayerEvent;
import net.minecraft.item.crafting.CraftingManager; import net.minecraft.item.crafting.CraftingManager;
@ -16,6 +18,9 @@ public class CraftingHandler
@SubscribeEvent @SubscribeEvent
public void onItemCraftedEvent(PlayerEvent.ItemCraftedEvent event) 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);
}
} }
} }

View file

@ -73,5 +73,13 @@ public class Recipes
// Minium Stone // Minium Stone
RecipesAludel.getInstance().addRecipe(new ItemStack(ModItems.stoneMinium), new ItemStack(ModItems.stoneInert), new ItemStack(ModItems.alchemicalDust, 8, 3)); 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));
} }
} }

View file

@ -11,9 +11,9 @@ public class SlotAlchemicalBag extends Slot
private final EntityPlayer entityPlayer; private final EntityPlayer entityPlayer;
private ContainerAlchemicalBag containerAlchemicalBag; 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.entityPlayer = entityPlayer;
this.containerAlchemicalBag = containerAlchemicalBag; this.containerAlchemicalBag = containerAlchemicalBag;
} }

View file

@ -8,9 +8,9 @@ import net.minecraft.item.ItemStack;
public class SlotAludelOutput extends Slot 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 @Override

View file

@ -8,9 +8,9 @@ import net.minecraft.item.ItemStack;
public class SlotCalcinator extends Slot 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 @Override

View file

@ -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);
}
}

View file

@ -0,0 +1,6 @@
package com.pahimar.ee3.item;
public interface IOwnable
{
}

View file

@ -6,6 +6,7 @@ import com.pahimar.ee3.reference.GuiIds;
import com.pahimar.ee3.reference.Names; import com.pahimar.ee3.reference.Names;
import com.pahimar.ee3.reference.Textures; import com.pahimar.ee3.reference.Textures;
import com.pahimar.ee3.util.ColorHelper; import com.pahimar.ee3.util.ColorHelper;
import com.pahimar.ee3.util.ItemHelper;
import com.pahimar.ee3.util.NBTHelper; import com.pahimar.ee3.util.NBTHelper;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
@ -21,7 +22,7 @@ import net.minecraft.world.World;
import java.util.List; 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"}; private static final String[] ALCHEMICAL_BAG_ICONS = {"open", "closed", "symbolTier1", "symbolTier2", "symbolTier3"};
@ -95,6 +96,9 @@ public class ItemAlchemicalBag extends ItemEE
{ {
if (!world.isRemote) if (!world.isRemote)
{ {
// Set the owner
ItemHelper.setOwner(itemStack, entityPlayer);
// Set a UUID on the Alchemical Bag, if one doesn't exist already // Set a UUID on the Alchemical Bag, if one doesn't exist already
NBTHelper.setUUID(itemStack); NBTHelper.setUUID(itemStack);
NBTHelper.setBoolean(itemStack, Names.NBT.ALCHEMICAL_BAG_GUI_OPEN, true); NBTHelper.setBoolean(itemStack, Names.NBT.ALCHEMICAL_BAG_GUI_OPEN, true);

View file

@ -2,7 +2,7 @@ package com.pahimar.ee3.item;
import com.pahimar.ee3.reference.Names; import com.pahimar.ee3.reference.Names;
public class ItemAlchemicalTome extends ItemEE public class ItemAlchemicalTome extends ItemEE implements IOwnable
{ {
public ItemAlchemicalTome() public ItemAlchemicalTome()
{ {

View file

@ -11,16 +11,18 @@ import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemPickaxe; import net.minecraft.item.ItemPickaxe;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.common.ForgeHooks;
public class ItemMatterPickAxe extends ItemPickaxe implements IKeyBound, IChargeable public class ItemMatterPickAxe extends ItemPickaxe implements IKeyBound, IChargeable
{ {
private short maxChargeLevel; private short maxChargeLevel;
public ItemMatterPickAxe(ToolMaterial toolMaterial1, int maxChargeLevel) public ItemMatterPickAxe(ToolMaterial toolMaterial, int maxChargeLevel)
{ {
super(toolMaterial1); super(toolMaterial);
this.maxChargeLevel = (short) maxChargeLevel; this.maxChargeLevel = (short) maxChargeLevel;
this.setCreativeTab(CreativeTab.EE3_TAB); this.setCreativeTab(CreativeTab.EE3_TAB);
this.setNoRepair(); this.setNoRepair();
@ -77,7 +79,7 @@ public class ItemMatterPickAxe extends ItemPickaxe implements IKeyBound, ICharge
@Override @Override
public float getDigSpeed(ItemStack itemStack, Block block, int meta) 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); return super.getDigSpeed(itemStack, block, meta) + (((IChargeable) itemStack.getItem()).getChargeLevel(itemStack) * 12f);
} }

View file

@ -1,5 +1,6 @@
package com.pahimar.ee3.proxy; package com.pahimar.ee3.proxy;
import com.pahimar.ee3.handler.CraftingHandler;
import com.pahimar.ee3.handler.ItemEventHandler; import com.pahimar.ee3.handler.ItemEventHandler;
import com.pahimar.ee3.handler.PlayerEventHandler; import com.pahimar.ee3.handler.PlayerEventHandler;
import com.pahimar.ee3.handler.WorldEventHandler; import com.pahimar.ee3.handler.WorldEventHandler;
@ -14,11 +15,14 @@ public abstract class CommonProxy implements IProxy
public void registerEventHandlers() public void registerEventHandlers()
{ {
ItemEventHandler itemEventHandler = new ItemEventHandler(); ItemEventHandler itemEventHandler = new ItemEventHandler();
CraftingHandler craftingHandler = new CraftingHandler();
FMLCommonHandler.instance().bus().register(itemEventHandler); FMLCommonHandler.instance().bus().register(itemEventHandler);
MinecraftForge.EVENT_BUS.register(itemEventHandler); MinecraftForge.EVENT_BUS.register(itemEventHandler);
MinecraftForge.EVENT_BUS.register(new WorldEventHandler()); MinecraftForge.EVENT_BUS.register(new WorldEventHandler());
MinecraftForge.EVENT_BUS.register(new PlayerEventHandler()); MinecraftForge.EVENT_BUS.register(new PlayerEventHandler());
FMLCommonHandler.instance().bus().register(craftingHandler);
MinecraftForge.EVENT_BUS.register(craftingHandler);
} }
public void registerTileEntities() public void registerTileEntities()

View file

@ -3,6 +3,7 @@ package com.pahimar.ee3.reference;
public class Messages public class Messages
{ {
public static final String UPGRADES_CHESTS = "tooltip.ee3:upgradesPrefix"; public static final String UPGRADES_CHESTS = "tooltip.ee3:upgradesPrefix";
public static final String NO_OWNER = "tooltip.ee3:none";
/* Fingerprint check related constants */ /* 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."; 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.";

View file

@ -74,6 +74,8 @@ public class Names
public static final String CUSTOM_NAME = "CustomName"; public static final String CUSTOM_NAME = "CustomName";
public static final String DIRECTION = "teDirection"; public static final String DIRECTION = "teDirection";
public static final String OWNER = "owner"; 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 public static final class Containers

View file

@ -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;
}
}

View file

@ -1,9 +1,14 @@
package com.pahimar.ee3.util; 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.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import java.util.Comparator; import java.util.Comparator;
import java.util.UUID;
public class ItemHelper public class ItemHelper
{ {
@ -97,4 +102,36 @@ public class ItemHelper
return "null"; 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());
}
} }

View file

@ -87,6 +87,7 @@ tooltip.ee3:upgradesPrefix=Upgrades (Alchemical) Chests
tooltip.ee3:alchemicalChestPrefix.small=Small tooltip.ee3:alchemicalChestPrefix.small=Small
tooltip.ee3:alchemicalChestPrefix.medium=Medium tooltip.ee3:alchemicalChestPrefix.medium=Medium
tooltip.ee3:alchemicalChestPrefix.large=Large tooltip.ee3:alchemicalChestPrefix.large=Large
tooltip.ee3:none=None
# Creative Tabs # Creative Tabs
itemGroup.ee3=Equivalent Exchange 3 itemGroup.ee3=Equivalent Exchange 3