From b1aa7032fe9e6bfedccf1bb08952c68100002489 Mon Sep 17 00:00:00 2001 From: Draknyte1 Date: Mon, 10 Oct 2016 23:17:59 +1000 Subject: + Added Blueprints - These are capable of storing a crafting recipe in it, to be used with the workbench. % More Internal work on the Workbench and it's handling of shit. + Added an interface for blueprints and other shit to utilize. --- .../core/item/general/ItemBlueprint.java | 164 +++++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100644 src/Java/gtPlusPlus/core/item/general/ItemBlueprint.java (limited to 'src/Java/gtPlusPlus/core/item/general') diff --git a/src/Java/gtPlusPlus/core/item/general/ItemBlueprint.java b/src/Java/gtPlusPlus/core/item/general/ItemBlueprint.java new file mode 100644 index 0000000000..a15616711d --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/general/ItemBlueprint.java @@ -0,0 +1,164 @@ +package gtPlusPlus.core.item.general; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.interfaces.IItemBlueprint; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.math.MathUtils; + +import java.util.List; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; +import cpw.mods.fml.common.registry.GameRegistry; + +public class ItemBlueprint extends Item implements IItemBlueprint{ + + protected String mName = ""; + protected boolean mHasBlueprint = false; + private final int bpID; + + /** + * The inventory of items the blueprint holds~ + */ + protected ItemStack[] blueprint = new ItemStack[9]; + + public ItemBlueprint(String unlocalizedName) { + this.setUnlocalizedName(unlocalizedName); + this.setTextureName(CORE.MODID + ":" + unlocalizedName); + this.setMaxStackSize(1); + this.setCreativeTab(AddToCreativeTab.tabMachines); + this.bpID = MathUtils.randInt(0, 1000); + GameRegistry.registerItem(this, unlocalizedName); + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + if (bpID >= 0){ + list.add(EnumChatFormatting.GRAY+"Technical Document No. "+bpID); + } + if(mHasBlueprint){ + list.add(EnumChatFormatting.BLUE+"Currently holding a blueprint for "+mName); + } + else { + list.add(EnumChatFormatting.RED+"Currently not holding a blueprint for anything."); + } + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + public String getItemStackDisplayName(ItemStack p_77653_1_) { + return "Blueprint"; + } + + @Override + public void onCreated(ItemStack itemStack, World world, EntityPlayer player) { + itemStack.stackTagCompound = new NBTTagCompound(); + //this.inventory = null; + //itemStack.stackTagCompound.set("pos_x", bed_X); TODO + } + + @Override + public void onUpdate(ItemStack itemStack, World par2World, Entity par3Entity, int par4, boolean par5) { + + } + + @Override + public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer par3Entity) { + //Let the player know what blueprint is held + Utils.messagePlayer(par3Entity, "This is a placeholder."); + return super.onItemRightClick(itemStack, world, par3Entity); + } + + public void readFromNBT(NBTTagCompound nbt){ + NBTTagList list = nbt.getTagList("Items", 10); + blueprint = new ItemStack[INV_SIZE]; + for(int i = 0;i= 0 && slot < INV_SIZE) + { + blueprint[slot] = ItemStack.loadItemStackFromNBT(data); + } + } + } + + public void writeToNBT(NBTTagCompound nbt){ + NBTTagList list = new NBTTagList(); + for(int i = 0;i