diff options
| author | Draknyte1 <Draknyte1@hotmail.com> | 2016-09-07 16:36:25 +1000 |
|---|---|---|
| committer | Draknyte1 <Draknyte1@hotmail.com> | 2016-09-07 16:36:25 +1000 |
| commit | 221c2f0fe81430e7dd4087e5f5845bd7c62ec56d (patch) | |
| tree | d6e0faaef01b9d517828557e1be82500d476f95e /src/Java/gtPlusPlus/core/item/base | |
| parent | 5872c0947ce7bc788b03fa2fb690b8815d3d0a04 (diff) | |
| download | GT5-Unofficial-221c2f0fe81430e7dd4087e5f5845bd7c62ec56d.tar.gz GT5-Unofficial-221c2f0fe81430e7dd4087e5f5845bd7c62ec56d.tar.bz2 GT5-Unofficial-221c2f0fe81430e7dd4087e5f5845bd7c62ec56d.zip | |
% Refactored the entire project to stop using MiscUtils everywhere possible, now it's gtPlusPlus.
Diffstat (limited to 'src/Java/gtPlusPlus/core/item/base')
23 files changed, 2120 insertions, 0 deletions
diff --git a/src/Java/gtPlusPlus/core/item/base/BaseItemBackpack.java b/src/Java/gtPlusPlus/core/item/base/BaseItemBackpack.java new file mode 100644 index 0000000000..316f922639 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/BaseItemBackpack.java @@ -0,0 +1,89 @@ +package gtPlusPlus.core.item.base; + +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.GTplusplus; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.handler.GuiHandler; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.core.util.math.MathUtils; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class BaseItemBackpack extends Item{ + + protected final int colourValue; + protected final String unlocalName; + + + public BaseItemBackpack(String unlocalizedName, int colour){ + this.unlocalName = unlocalizedName; + this.setUnlocalizedName(unlocalizedName); + this.setTextureName(CORE.MODID + ":" + "itemBackpack"); + this.colourValue = colour; + GameRegistry.registerItem(this, unlocalizedName); + GT_OreDictUnificator.registerOre("storageBackpack", UtilsItems.getSimpleStack(this)); + setMaxStackSize(1); + setCreativeTab(AddToCreativeTab.tabOther); + } + + // Without this method, your inventory will NOT work!!! + @Override + public int getMaxItemUseDuration(ItemStack stack) { + return 1; // return any value greater than zero + } + + @Override + public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player) + { + if (!world.isRemote) + { + // If player not sneaking, open the inventory gui + if (!player.isSneaking()) { + player.openGui(GTplusplus.instance, GuiHandler.GUI3, world, 0, 0, 0); + } + + // Otherwise, stealthily place some diamonds in there for a nice surprise next time you open it up :) + else { + // Utils.LOG_INFO("Player is Sneaking, giving them sneaky diamonds."); + // new BaseInventoryBackpack(player.getHeldItem()).setInventorySlotContents(0, new ItemStack(Items.diamond,4)); + } + } + + return itemstack; + } + + @Override + public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { + if (colourValue == 0){ + return MathUtils.generateSingularRandomHexValue(); + } + return colourValue; + + } + + @Override + public String getItemStackDisplayName(ItemStack p_77653_1_) { + //Name Formatting. + String temp = unlocalName.replace("backpack", ""); + //Lets find the colour. + if (temp.toLowerCase().contains("dark")){ + temp = unlocalName.substring(12, unlocalName.length()); + temp = "Dark "+ temp; + } + return (temp+" Backpack"); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconRegister) + { + this.itemIcon = iconRegister.registerIcon(CORE.MODID + ":" + "itemBackpack"); + } +} diff --git a/src/Java/gtPlusPlus/core/item/base/BaseItemGeneric.java b/src/Java/gtPlusPlus/core/item/base/BaseItemGeneric.java new file mode 100644 index 0000000000..a6cc29497e --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/BaseItemGeneric.java @@ -0,0 +1,30 @@ +package gtPlusPlus.core.item.base; + +import gtPlusPlus.core.lib.CORE; + +import java.util.List; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + +public class BaseItemGeneric extends Item +{ + public BaseItemGeneric(String unlocalizedName, CreativeTabs c, int stackSize, int maxDmg) + { + setUnlocalizedName(CORE.MODID + "_" + unlocalizedName); + setTextureName(CORE.MODID + ":" + unlocalizedName); + setCreativeTab(c); + setMaxStackSize(stackSize); + setMaxDamage(maxDmg); + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + list.add(EnumChatFormatting.GOLD+""); + super.addInformation(stack, aPlayer, list, bool); + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/item/base/BaseItemWithCharge.java b/src/Java/gtPlusPlus/core/item/base/BaseItemWithCharge.java new file mode 100644 index 0000000000..c793776e37 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/BaseItemWithCharge.java @@ -0,0 +1,75 @@ +package gtPlusPlus.core.item.base; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; + +import java.util.List; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; + +public class BaseItemWithCharge extends Item{ + + public int int_Charge = 0; + public int int_Max_Charge = 0; + + public BaseItemWithCharge(String unlocalizedName, int constructor_Charge, int constructor_Max_Charge) { + this.setUnlocalizedName(unlocalizedName); + this.setTextureName(CORE.MODID + ":" + unlocalizedName); + this.setMaxStackSize(1); + this.setCreativeTab(AddToCreativeTab.tabMachines); + this.int_Charge = constructor_Charge; + this.int_Max_Charge = constructor_Max_Charge; + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + int NBT_Charge = int_Charge; + int NBT_Max_Charge = int_Max_Charge; + if (stack.stackTagCompound != null) { + NBT_Charge = stack.stackTagCompound.getInteger("charge_Current"); + NBT_Max_Charge = stack.stackTagCompound.getInteger("charge_Max"); + String tempX = String.valueOf(NBT_Charge); + String tempY = String.valueOf(NBT_Max_Charge); + String formattedX = EnumChatFormatting.RED+tempX+EnumChatFormatting.GRAY; + String formattedY = EnumChatFormatting.DARK_RED+tempY+EnumChatFormatting.GRAY; + list.add(EnumChatFormatting.GRAY+"Charge:"+formattedX+"/"+formattedY+"."); + super.addInformation(stack, aPlayer, list, bool); + } + } + + //Ticking and NBT Handling + /* Called each tick as long the item is on a player inventory. Uses by maps to check if is on a player hand and + * update it's contents. + * + * public int fuelRemaining = 0; + public int maximumFuel = 0; + public String fuelType = ""; + public float heat = 0; + public float maxHeat = 5000; + * + */ + @Override + public void onCreated(ItemStack itemStack, World world, EntityPlayer player) { + + } + + @Override + public void onUpdate(ItemStack itemStack, World par2World, Entity par3Entity, int par4, boolean par5) { + + } + + @Override + public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer par3Entity) { + itemStack.stackTagCompound = new NBTTagCompound(); + return super.onItemRightClick(itemStack, world, par3Entity); + } + + + +} diff --git a/src/Java/gtPlusPlus/core/item/base/BaseItemWithDamageValue.java b/src/Java/gtPlusPlus/core/item/base/BaseItemWithDamageValue.java new file mode 100644 index 0000000000..ec052ef1f9 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/BaseItemWithDamageValue.java @@ -0,0 +1,29 @@ +package gtPlusPlus.core.item.base; + +import gtPlusPlus.core.lib.CORE; + +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + +public class BaseItemWithDamageValue extends Item{ + public BaseItemWithDamageValue(String unlocalizedName) { + this.setUnlocalizedName(unlocalizedName); + this.setTextureName(CORE.MODID + ":" + unlocalizedName); + this.setMaxStackSize(1); + this.setMaxDamage(100); + } + @Override + public void setDamage(ItemStack stack, int damage) { + super.setDamage(stack, damage); + } + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + list.add(EnumChatFormatting.GOLD+""); + super.addInformation(stack, aPlayer, list, bool); + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/item/base/BasicSpawnEgg.java b/src/Java/gtPlusPlus/core/item/base/BasicSpawnEgg.java new file mode 100644 index 0000000000..9407689cfc --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/BasicSpawnEgg.java @@ -0,0 +1,259 @@ +package gtPlusPlus.core.item.base; + + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.util.Utils; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockLiquid; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityList; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemMonsterPlacer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Facing; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + + + +public class BasicSpawnEgg extends ItemMonsterPlacer +{ + @SideOnly(Side.CLIENT) + private IIcon theIcon; + protected int colorBase = 0x000000; + protected int colorSpots = 0xFFFFFF; + protected String entityMODID = ""; + protected String entityToSpawnName = ""; + protected String entityToSpawnNameFull = ""; + protected EntityLiving entityToSpawn = null; + + public BasicSpawnEgg(){ + super(); + } + + public BasicSpawnEgg(String MODID, String parEntityToSpawnName, int parPrimaryColor, int parSecondaryColor){ + setHasSubtypes(false); + maxStackSize = 64; + setCreativeTab(AddToCreativeTab.tabOther); + setEntityToSpawnName(parEntityToSpawnName); + colorBase = parPrimaryColor; + colorSpots = parSecondaryColor; + entityMODID = MODID; + + // DEBUG + Utils.LOG_WARNING("Spawn egg constructor for "+entityToSpawnName); + } + + /** + * Callback for item usage. If the item does something special on right clicking, + + * he will have one of those. Return + * True if something happen and false if it don't. This is for ITEMS, not BLOCKS + */ + @Override + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10){ + if (par3World.isRemote) + { + return true; + } + Block block = par3World.getBlock(par4, par5, par6); + par4 += Facing.offsetsXForSide[par7]; + par5 += Facing.offsetsYForSide[par7]; + par6 += Facing.offsetsZForSide[par7]; + double d0 = 0.0D; + + if (par7 == 1 && block.getRenderType() == 11) + { + d0 = 0.5D; + } + + Entity entity = spawnEntity(par3World, par4 + 0.5D, par5 + d0, par6 + 0.5D); + + if (entity != null) + { + if (entity instanceof EntityLivingBase && par1ItemStack.hasDisplayName()) + { + ((EntityLiving)entity).setCustomNameTag(par1ItemStack.getDisplayName()); + } + + if (!par2EntityPlayer.capabilities.isCreativeMode) + { + --par1ItemStack.stackSize; + } + } + + return true; + } + + /** + * Called whenever this item is equipped and the right mouse button is pressed. + + *Args: itemStack, world, entityPlayer + */ + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer){ + if (par2World.isRemote) + { + return par1ItemStack; + } + MovingObjectPosition movingobjectposition = getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, true); + + if (movingobjectposition == null) + { + return par1ItemStack; + } + if (movingobjectposition.typeOfHit == MovingObjectPosition + + .MovingObjectType.BLOCK) + + { + int i = movingobjectposition.blockX; + int j = movingobjectposition.blockY; + int k = movingobjectposition.blockZ; + + if (!par2World.canMineBlock(par3EntityPlayer, i, j, k)) + { + return par1ItemStack; + } + + if (!par3EntityPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, par1ItemStack)) + { + return par1ItemStack; + } + + if (par2World.getBlock(i, j, k) instanceof BlockLiquid) + { + Entity entity = spawnEntity(par2World, i, j, k); + + if (entity != null) + { + if (entity instanceof EntityLivingBase && par1ItemStack.hasDisplayName()) + { + ((EntityLiving)entity).setCustomNameTag(par1ItemStack.getDisplayName()); + } + + if (!par3EntityPlayer.capabilities.isCreativeMode) + { + --par1ItemStack.stackSize; + } + } + } + } + + return par1ItemStack; + } + + /** + * Spawns the creature specified by the egg's type in the location specified by + + * the last three parameters. + * Parameters: world, entityID, x, y, z. + */ + public Entity spawnEntity(World parWorld, double parX, double parY, double parZ){ + + if (!parWorld.isRemote) // never spawn entity on client side + { + entityToSpawnNameFull = entityMODID+"."+entityToSpawnName; + if (EntityList.stringToClassMapping.containsKey(entityToSpawnNameFull)) + { + entityToSpawn = (EntityLiving) EntityList + + .createEntityByName(entityToSpawnNameFull, parWorld); + entityToSpawn.setLocationAndAngles(parX, parY, parZ, + + MathHelper.wrapAngleTo180_float(parWorld.rand.nextFloat() + + * 360.0F), 0.0F); + parWorld.spawnEntityInWorld(entityToSpawn); + entityToSpawn.onSpawnWithEgg((IEntityLivingData)null); + entityToSpawn.playLivingSound(); + } + else + { + //DEBUG + Utils.LOG_WARNING("Entity not found "+entityToSpawnName); + } + } + + return entityToSpawn; + } + + + /** + * returns a list of items with the same ID, but different meta (eg: dye returns 16 items) + */ + @Override + @SideOnly(Side.CLIENT) + public void getSubItems(Item parItem, CreativeTabs parTab, List parList){ + parList.add(new ItemStack(parItem, 1, 0)); + } + + @Override + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(ItemStack par1ItemStack, int parColorType){ + return (parColorType == 0) ? colorBase : colorSpots; + } + + @Override + @SideOnly(Side.CLIENT) + public boolean requiresMultipleRenderPasses(){ + return true; + } + + @Override + // Doing this override means that there is no localization for language + // unless you specifically check for localization here and convert + public String getItemStackDisplayName(ItemStack par1ItemStack){ + return "Spawn "+entityToSpawnName; + } + + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister){ + super.registerIcons(par1IconRegister); + theIcon = par1IconRegister.registerIcon(getIconString() + "_overlay"); + } + + /** + * Gets an icon index based on an item's damage value and the given render pass + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamageForRenderPass(int parDamageVal, int parRenderPass){ + return parRenderPass > 0 ? theIcon : super.getIconFromDamageForRenderPass(parDamageVal, parRenderPass); + } + + public void setColors(int parColorBase, int parColorSpots){ + colorBase = parColorBase; + colorSpots = parColorSpots; + } + + public int getColorBase(){ + return colorBase; + } + + public int getColorSpots(){ + return colorSpots; + } + + public void setEntityToSpawnName(String parEntityToSpawnName){ + entityToSpawnName = parEntityToSpawnName; + entityToSpawnNameFull = entityMODID+"."+entityToSpawnName; + } + +} + diff --git a/src/Java/gtPlusPlus/core/item/base/CoreItem.java b/src/Java/gtPlusPlus/core/item/base/CoreItem.java new file mode 100644 index 0000000000..b77b2d336e --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/CoreItem.java @@ -0,0 +1,118 @@ +package gtPlusPlus.core.item.base; + +import gtPlusPlus.core.lib.CORE; + +import java.util.List; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class CoreItem extends Item +{ + + private final EnumRarity rarity; + private final EnumChatFormatting descColour; + private final String itemDescription; + private final boolean hasEffect; + + //0 + /* + * Name, Tab - 64 Stack, 0 Dmg + */ + public CoreItem(String unlocalizedName, CreativeTabs creativeTab) + { + this(unlocalizedName, creativeTab, 64, 0); //Calls 3 + } + //1 + /* + * Name, Tab, Stack - 0 Dmg + */ + public CoreItem(String unlocalizedName, CreativeTabs creativeTab, int stackSize) + { + this(unlocalizedName, creativeTab, stackSize, 0); //Calls 3 + } + //2 + /* + * Name, Tab, Stack, Description - 0 Dmg + */ + public CoreItem(String unlocalizedName, CreativeTabs creativeTab, int stackSize, String description) + { + this(unlocalizedName, creativeTab, stackSize, 0, description); //Calls 4 + } + //3 + /* + * Name, Tab, Stack, Dmg - Description + */ + public CoreItem(String unlocalizedName, CreativeTabs creativeTab, int stackSize, int maxDmg) + { + this(unlocalizedName, creativeTab, stackSize, maxDmg, ""); //Calls 4 + } + //4 //Not Rare + basic tooltip + /* + * Name, Tab, Stack, Dmg, Description + */ + public CoreItem(String unlocalizedName, CreativeTabs creativeTab, int stackSize, int maxDmg, String description) + { + this(unlocalizedName, creativeTab, stackSize, maxDmg, description, EnumRarity.common, EnumChatFormatting.GRAY, false); //Calls 4.5 + } + //4.5 + /* + * Name, Tab, Stack, Dmg, Description, Text Colour - Common + */ + public CoreItem(String unlocalizedName, CreativeTabs creativeTab, int stackSize, int maxDmg, String description, EnumChatFormatting colour) + { + this(unlocalizedName, creativeTab, stackSize, maxDmg, description, EnumRarity.common, colour, false); //Calls 5 + } + + //4.75 + /* + * Name, Tab, Stack, Dmg, Description, Rarity - Gray text + */ + public CoreItem(String unlocalizedName, CreativeTabs creativeTab, int stackSize, int maxDmg, String description, EnumRarity rarity) + { + this(unlocalizedName, creativeTab, stackSize, maxDmg, description, rarity, EnumChatFormatting.GRAY, false); //Calls 5 + } + + //5 + /* + * Name, Tab, Stack, Dmg, Description, Rarity, Text Colour, Effect + */ + public CoreItem(String unlocalizedName, CreativeTabs creativeTab, int stackSize, int maxDmg, String description, EnumRarity regRarity, EnumChatFormatting colour, boolean Effect) + { + setUnlocalizedName(unlocalizedName); + setTextureName(CORE.MODID + ":" + unlocalizedName); + setCreativeTab(creativeTab); + setMaxStackSize(stackSize); + setMaxDamage(maxDmg); + this.rarity = regRarity; + this.itemDescription = description; + this.descColour = colour; + this.hasEffect = Effect; + GameRegistry.registerItem(this, unlocalizedName); + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + list.add(descColour+itemDescription); + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + @SideOnly(Side.CLIENT) + public EnumRarity getRarity(ItemStack par1ItemStack){ + return rarity; + } + + @Override + public boolean hasEffect(ItemStack par1ItemStack){ + return hasEffect; + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/item/base/bolts/BaseItemBolt.java b/src/Java/gtPlusPlus/core/item/base/bolts/BaseItemBolt.java new file mode 100644 index 0000000000..0f56730177 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/bolts/BaseItemBolt.java @@ -0,0 +1,82 @@ +package gtPlusPlus.core.item.base.bolts; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.core.util.math.MathUtils; + +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import cpw.mods.fml.common.registry.GameRegistry; + +public class BaseItemBolt extends Item{ + + protected int colour; + protected String materialName; + protected String unlocalName; + private int mTier; + + public BaseItemBolt(String unlocalizedName, String materialName, int colour, int tier) { + setUnlocalizedName(unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setUnlocalizedName(unlocalizedName); + this.unlocalName = unlocalizedName; + this.setMaxStackSize(64); + this.setTextureName(CORE.MODID + ":" + "itemBolt"); + this.colour = colour; + this.mTier = tier; + this.materialName = materialName; + GameRegistry.registerItem(this, unlocalizedName); + GT_OreDictUnificator.registerOre(unlocalName.replace("itemB", "b"), UtilsItems.getSimpleStack(this)); + addExtruderRecipe(); + } + + @Override + public String getItemStackDisplayName(ItemStack p_77653_1_) { + + return (materialName+ " Bolt"); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + if (materialName != null && materialName != "" && !materialName.equals("")){ + list.add(EnumChatFormatting.GRAY+"A small Bolt, constructed from " + materialName + "."); + } + super.addInformation(stack, aPlayer, list, bool); + } + + public final String getMaterialName() { + return materialName; + } + + @Override + public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { + if (colour == 0){ + return MathUtils.generateSingularRandomHexValue(); + } + return colour; + + } + + private void addExtruderRecipe(){ + Utils.LOG_WARNING("Adding recipe for "+materialName+" Bolts"); + String tempIngot = unlocalName.replace("itemBolt", "ingot"); + ItemStack tempOutputStack = UtilsItems.getItemStackOfAmountFromOreDict(tempIngot, 1); + if (null != tempOutputStack){ + GT_Values.RA.addExtruderRecipe(tempOutputStack, + ItemList.Shape_Extruder_Bolt.get(1), + UtilsItems.getSimpleStack(this, 8), + 30*mTier*20, + 24*mTier); + } + } + +} diff --git a/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDust.java b/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDust.java new file mode 100644 index 0000000000..6d12624487 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDust.java @@ -0,0 +1,352 @@ +package gtPlusPlus.core.item.base.dusts; + +import static gtPlusPlus.core.creative.AddToCreativeTab.tabMisc; +import gregtech.api.enums.GT_Values; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.MaterialInfo; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.recipe.UtilsRecipe; + +import java.util.List; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; +import cpw.mods.fml.common.registry.GameRegistry; + +public class BaseItemDust extends Item{ + + protected int colour; + protected String materialName; + protected String pileType; + protected boolean useBlastFurnace; + String name = ""; + private int mTier; + private MaterialInfo dustInfo; + + public BaseItemDust(String unlocalizedName, String materialName, MaterialInfo matInfo, int colour, String pileSize, boolean blastFurnaceRequired, int tier, int sRadioactivity) { + setUnlocalizedName(unlocalizedName); + this.setUnlocalizedName(unlocalizedName); + this.setMaxStackSize(64); + if (pileSize == "dust" || pileSize == "Dust"){ + this.setTextureName(CORE.MODID + ":" + "dust");} + else{ + this.setTextureName(CORE.MODID + ":" + "dust"+pileSize);} + this.setCreativeTab(tabMisc); + this.colour = colour; + this.mTier = tier; + this.materialName = materialName; + this.useBlastFurnace = blastFurnaceRequired; + this.dustInfo = matInfo; + this.sRadiation = sRadioactivity; + GameRegistry.registerItem(this, unlocalizedName); + + String temp = ""; + Utils.LOG_WARNING("Unlocalized name for OreDict nameGen: "+getUnlocalizedName()); + if (getUnlocalizedName().contains("item.")){ + temp = getUnlocalizedName().replace("item.", ""); + Utils.LOG_WARNING("Generating OreDict Name: "+temp); + } + else { + temp = getUnlocalizedName(); + } + if (temp.contains("DustTiny")){ + temp = temp.replace("itemD", "d"); + Utils.LOG_WARNING("Generating OreDict Name: "+temp); + } + else if (temp.contains("DustSmall")){ + temp = temp.replace("itemD", "d"); + Utils.LOG_WARNING("Generating OreDict Name: "+temp); + } + else { + temp = temp.replace("itemD", "d"); + Utils.LOG_WARNING("Generating OreDict Name: "+temp); + } + if (temp != null && temp != ""){ + GT_OreDictUnificator.registerOre(temp, UtilsItems.getSimpleStack(this)); + } + addMixerRecipe(); + addFurnaceRecipe(); + addMacerationRecipe(); + } + + @Override + public String getItemStackDisplayName(ItemStack iStack) { + + if (getUnlocalizedName().contains("DustTiny")){ + name = "Tiny Pile of "+materialName + " Dust"; + } + else if (getUnlocalizedName().contains("DustSmall")){ + name = "Small Pile of "+materialName + " Dust"; + } + else { + name = materialName + " Dust"; + } + return name; + } + + protected final int sRadiation; + @Override + public void onUpdate(ItemStack iStack, World world, Entity entityHolding, int p_77663_4_, boolean p_77663_5_) { + Utils.applyRadiationDamageToEntity(sRadiation, world, entityHolding); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + //if (pileType != null && materialName != null && pileType != "" && materialName != "" && !pileType.equals("") && !materialName.equals("")){ + if (getUnlocalizedName().contains("DustTiny")){ + list.add(EnumChatFormatting.GRAY+"A tiny pile of " + materialName + " dust."); + } + else if (getUnlocalizedName().contains("DustSmall")){ + list.add(EnumChatFormatting.GRAY+"A small pile of " + materialName + " dust."); + } + else { + list.add(EnumChatFormatting.GRAY+"A pile of " + materialName + " dust."); + } + if (sRadiation > 0){ + list.add(CORE.GT_Tooltip_Radioactive); + } + //} + super.addInformation(stack, aPlayer, list, bool); + } + + public final String getMaterialName() { + return materialName; + } + + @Override + public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { + if (colour == 0){ + return MathUtils.generateSingularRandomHexValue(); + } + return colour; + + } + + + + private void addMixerRecipe(){ + ItemStack tempStack = UtilsItems.getSimpleStack(this); + ItemStack tempOutput = null; + ItemStack[] inputStacks = dustInfo.getInputs(); + ItemStack[] outputStacks = dustInfo.getOutputs(); + String temp = ""; + Utils.LOG_WARNING("Unlocalized name for OreDict nameGen: "+getUnlocalizedName()); + if (getUnlocalizedName().contains("item.")){ + temp = getUnlocalizedName().replace("item.", ""); + Utils.LOG_WARNING("Generating OreDict Name: "+temp); + } + else { + temp = getUnlocalizedName(); + } + if (temp.contains("DustTiny")){ + temp = temp.replace("itemDustTiny", "dust"); + Utils.LOG_WARNING("Generating OreDict Name: "+temp); + } + else if (temp.contains("DustSmall")){ + temp = temp.replace("itemDustSmall", "dust"); + Utils.LOG_WARNING("Generating OreDict Name: "+temp); + } + else { + temp = temp.replace("itemD", "d"); + Utils.LOG_WARNING("Generating OreDict Name: "+temp); + } + if (temp != null && temp != ""){ + + if (getUnlocalizedName().contains("DustTiny") || getUnlocalizedName().contains("DustSmall")){ + tempOutput = UtilsItems.getItemStackOfAmountFromOreDict(temp, 1); + } + else { + if (outputStacks[0] != null){ + Utils.LOG_WARNING("Getting output dusts for mixer recipe. Checking ENUM, got: "+outputStacks[0].toString()); + tempOutput = outputStacks[0]; + } + else { + Utils.LOG_WARNING("Getting output dusts for mixer recipe. Enum check failed, failback item is: "+temp); + tempOutput = UtilsItems.getItemStackOfAmountFromOreDict(temp, 1); + } + } + + } + + if (tempOutput != null){ + if (getUnlocalizedName().contains("DustTiny")){ + Utils.LOG_WARNING("Generating a 9 Tiny dust to 1 Dust recipe for "+materialName); + UtilsRecipe.addShapelessGregtechRecipe(tempOutput, + tempStack, tempStack, tempStack, + tempStack, tempStack, tempStack, + tempStack, tempStack, tempStack); + } + else if (getUnlocalizedName().contains("DustSmall")){ + Utils.LOG_WARNING("Generating a 4 Small dust to 1 Dust recipe for "+materialName); + UtilsRecipe.addShapelessGregtechRecipe(tempOutput, + tempStack, tempStack, null, + tempStack, tempStack, null, + null, null, null); + } + else { + Utils.LOG_WARNING("Generating a Dust recipe for "+materialName+" in the mixer."); + + + int i = 0; + if (inputStacks.length >= 2){ + for (ItemStack is : inputStacks){ + if (is != null){ + Utils.LOG_WARNING("Found "+is.getDisplayName()+" as an input for mixer recipe."); + if (is.getDisplayName().toLowerCase().contains("tell alkalus")){ + ItemStack tempStackForAName = inputStacks[i]; + String[] inputList = dustInfo.getInputItemsAsList(); + int[] inputSizes = dustInfo.getInputStackSizesAsList(); + inputStacks[i] = UtilsItems.getItemStackOfAmountFromOreDict(inputList[i], inputSizes[i]); + Utils.LOG_WARNING("Swapping input slot "+i+" which contains "+tempStackForAName.getDisplayName()+" with "+inputStacks[i].getDisplayName()+"."); + } + + } + + else { + Utils.LOG_WARNING("Input "+i+" was null."); + } + + i++; + } + } + + GT_Values.RA.addMixerRecipe( + inputStacks[0], inputStacks[1], + inputStacks[2], inputStacks[3], + null, null, + tempOutput, + 8*mTier*20, 8*mTier*2); + + /*GT_Values.RA.addMixerRecipe( + GT_Utility.copyAmount(inputStacks[0].stackSize, new Object[]{inputStacks[0]}), GT_Utility.copyAmount(inputStacks[1].stackSize, new Object[]{inputStacks[1]}), + GT_Utility.copyAmount(inputStacks[2].stackSize, new Object[]{inputStacks[2]}), GT_Utility.copyAmount(inputStacks[3].stackSize, new Object[]{inputStacks[3]}), + null, null, + tempOutput, + 8*mTier*20, 8*mTier*2);*/ + + } + } + + } + + private void addMacerationRecipe(){ + Utils.LOG_WARNING("Adding recipe for "+materialName+" Dusts"); + + String tempIngot = getUnlocalizedName().replace("item.itemDust", "ingot"); + String tempDust = getUnlocalizedName().replace("item.itemDust", "dust"); + ItemStack tempInputStack; + ItemStack tempOutputStack; + + if (getUnlocalizedName().contains("DustSmall") || getUnlocalizedName().contains("DustTiny")){ + return; + } + + Utils.LOG_WARNING("Unlocalized name for OreDict nameGen: "+getUnlocalizedName()); + if (getUnlocalizedName().contains("item.")){ + tempIngot = getUnlocalizedName().replace("item.", ""); + Utils.LOG_WARNING("Generating OreDict Name: "+tempIngot); + } + else { + tempIngot = getUnlocalizedName(); + } + + tempIngot = tempIngot.replace("itemDust", "ingot"); + Utils.LOG_WARNING("Generating OreDict Name: "+tempIngot); + ItemStack[] outputStacks = dustInfo.getOutputs(); + if (tempIngot != null && tempIngot != ""){ + tempInputStack = UtilsItems.getItemStackOfAmountFromOreDict(tempIngot, 1); + tempOutputStack = UtilsItems.getItemStackOfAmountFromOreDict(tempDust, 1); + ItemStack tempStackOutput2; + int chance = mTier*10/MathUtils.randInt(10, 20); + if (outputStacks[1] != null && !outputStacks[1].getUnlocalizedName().toLowerCase().contains("aaa_broken")){ + tempStackOutput2 = outputStacks[1]; + tempOutputStack = outputStacks[0]; + } + else { + tempStackOutput2 = null; + } + if (null != tempOutputStack && null != tempInputStack){ + GT_ModHandler.addPulverisationRecipe(tempInputStack, tempOutputStack.splitStack(1), tempStackOutput2, chance); + } + } + } + + private void addFurnaceRecipe(){ + + String temp = ""; + if (getUnlocalizedName().contains("item.")){ + temp = getUnlocalizedName().replace("item.", ""); + } + else { + temp = getUnlocalizedName(); + } + if (temp.contains("DustTiny") || temp.contains("DustSmall")){ + return; + } + temp = temp.replace("itemDust", "ingot"); + if (temp != null && temp != ""){ + + if (this.useBlastFurnace){ + Utils.LOG_WARNING("Adding recipe for Hot "+materialName+" Ingots in a Blast furnace."); + String tempIngot = temp.replace("ingot", "ingotHot"); + ItemStack tempOutputStack = UtilsItems.getItemStackOfAmountFromOreDict(tempIngot, 1); + Utils.LOG_WARNING("This will produce "+tempOutputStack.getDisplayName() + " Debug: "+tempIngot); + if (null != tempOutputStack){ + addBlastFurnaceRecipe(UtilsItems.getSimpleStack(this), null, tempOutputStack, null, 350*mTier); + } + return; + } + Utils.LOG_WARNING("Adding recipe for "+materialName+" Ingots in a furnace."); + ItemStack tempOutputStack = UtilsItems.getItemStackOfAmountFromOreDict(temp, 1); + Utils.LOG_WARNING("This will produce an ingot of "+tempOutputStack.getDisplayName() + " Debug: "+temp); + if (null != tempOutputStack){ + if (mTier < 5){ + CORE.GT_Recipe.addSmeltingAndAlloySmeltingRecipe(UtilsItems.getSimpleStack(this), tempOutputStack); + } + else if (mTier >= 5){ + Utils.LOG_WARNING("Adding recipe for "+materialName+" Ingots in a Blast furnace."); + Utils.LOG_WARNING("This will produce "+tempOutputStack.getDisplayName()); + if (null != tempOutputStack){ + addBlastFurnaceRecipe(UtilsItems.getSimpleStack(this), null, tempOutputStack, null, 350*mTier); + } + return; + } + } + + } + } + + private void addBlastFurnaceRecipe(ItemStack input1, ItemStack input2, ItemStack output1, ItemStack output2, int tempRequired){ + //Special Cases + /*if (input1.getUnlocalizedName().toLowerCase().contains("tantalloy61")){ + Utils.LOG_INFO("Adding Special handler for Staballoy-61 in the Blast Furnace"); + input2 = UtilsItems.getItemStackOfAmountFromOreDict("dustTantalloy60", 2); + if (input2 == null){ + Utils.LOG_INFO("invalid itemstack."); + } + else { + Utils.LOG_INFO("Found "+input2.getDisplayName()); + } + }*/ + GT_Values.RA.addBlastRecipe( + input1, + input2, + GT_Values.NF, GT_Values.NF, + output1, + output2, + 250*mTier*20, + mTier*64, + tempRequired); + + + + } +} diff --git a/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDustAbstract.java b/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDustAbstract.java new file mode 100644 index 0000000000..a49dc58188 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDustAbstract.java @@ -0,0 +1,42 @@ +package gtPlusPlus.core.item.base.dusts; + +import gtPlusPlus.core.lib.CORE; + +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import cpw.mods.fml.common.registry.GameRegistry; + +public abstract class BaseItemDustAbstract extends Item{ + + protected int colour = 0; + protected String materialName; + protected String pileType; + + public BaseItemDustAbstract(String unlocalizedName, String materialName, int colour, String pileSize) { + this.setUnlocalizedName(unlocalizedName); + this.setMaxStackSize(64); + if (pileSize == "dust" || pileSize == "Dust"){ + this.setTextureName(CORE.MODID + ":" + "dust"); + } + else{ + this.setTextureName(CORE.MODID + ":" + "dust"+pileSize); + } + this.setMaxStackSize(64); + this.colour = colour; + this.materialName = materialName; + setUnlocalizedName(unlocalizedName); + GameRegistry.registerItem(this, unlocalizedName); + } + + @Override + public abstract void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool); + + public abstract String getMaterialName(); + + @Override + public abstract int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF); + +} diff --git a/src/Java/gtPlusPlus/core/item/base/foods/BaseItemFood.java b/src/Java/gtPlusPlus/core/item/base/foods/BaseItemFood.java new file mode 100644 index 0000000000..7b0663d9cf --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/foods/BaseItemFood.java @@ -0,0 +1,47 @@ +package gtPlusPlus.core.item.base.foods; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemFood; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.PotionEffect; +import net.minecraft.world.World; +import cpw.mods.fml.common.registry.GameRegistry; + +public class BaseItemFood extends ItemFood { + + private PotionEffect[] effects; + protected String localName; + + public BaseItemFood(String unlocalizedName, String localizedName, int healAmount, float saturationModifier, boolean wolvesFavorite, PotionEffect... effects) { + super(healAmount, saturationModifier, wolvesFavorite); + this.setUnlocalizedName(unlocalizedName); + this.setTextureName(CORE.MODID + ":" + unlocalizedName.replace("Hot", "")); + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.effects = effects; + this.localName = localizedName; + GameRegistry.registerItem(this, unlocalizedName); + } + + @Override + protected void onFoodEaten(ItemStack stack, World world, EntityPlayer player) { + super.onFoodEaten(stack, world, player); + + for (int i = 0; i < effects.length; i ++) { + if (!world.isRemote && effects[i] != null && effects[i].getPotionID() > 0) + player.addPotionEffect(new PotionEffect(this.effects[i].getPotionID(), + this.effects[i].getDuration(), this.effects[i].getAmplifier(), + this.effects[i].getIsAmbient() + ) + ); + } + } + + @Override + public String getItemStackDisplayName(ItemStack p_77653_1_) { + + return ("A Serving of "+localName); + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/item/base/foods/BaseItemHotFood.java b/src/Java/gtPlusPlus/core/item/base/foods/BaseItemHotFood.java new file mode 100644 index 0000000000..aaad22be9c --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/foods/BaseItemHotFood.java @@ -0,0 +1,78 @@ +package gtPlusPlus.core.item.base.foods; + +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.core.util.math.MathUtils; + +import java.util.List; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.DamageSource; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; + +public class BaseItemHotFood extends BaseItemFood{ + + protected String materialName; + protected String unlocalName; + protected int cooldownTime; + protected Item output; + + public BaseItemHotFood(String unlocalizedName, int healAmount, float healSaturation, String foodName, int timeToCoolInSeconds, Item cooledFood) { + super(unlocalizedName, "Hot "+foodName, healAmount, healSaturation, false); + this.unlocalName = unlocalizedName; + this.cooldownTime = timeToCoolInSeconds * 20; + this.materialName = foodName; + this.output = cooledFood; + this.setMaxStackSize(1); + } + + @Override + public ItemStack onEaten(ItemStack iStack, World world, EntityPlayer player) { + return super.onEaten(iStack, world, player); + } + + @Override + public void onUpdate(ItemStack iStack, World world, Entity entityHolding, int p_77663_4_, boolean p_77663_5_) { + //Utils.LOG_INFO("Item Damage: "+iStack.getItemDamage()+" Max Damage: "+iStack.getMaxDamage()); + if (!world.isRemote){ + if(iStack.getItemDamage() == cooldownTime) { + if (entityHolding instanceof EntityPlayer){ + Utils.LOG_INFO("Foods Done."); + ((EntityPlayer) entityHolding).inventory.addItemStackToInventory(UtilsItems.getSimpleStack(output)); + ((EntityPlayer) entityHolding).inventory.consumeInventoryItem(this); + } + }else if(iStack.getItemDamage() < cooldownTime){ + iStack.setItemDamage(iStack.getItemDamage() + 1); + } + if(MathUtils.divideXintoY(iStack.getItemDamage(), 150)){ + entityHolding.attackEntityFrom(DamageSource.onFire, 1); + } + + + } + super.onUpdate(iStack, world, entityHolding, p_77663_4_, p_77663_5_); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + if (materialName != null && materialName != "" && !materialName.equals("")){ + list.add(EnumChatFormatting.GRAY+"Warning: "+EnumChatFormatting.RED+"Very hot!"+EnumChatFormatting.GRAY+" Avoid direct handling.."); + list.add(EnumChatFormatting.GRAY+"This food has "+((cooldownTime-(int) stack.getItemDamage())/20)+" seconds left, until it is cool."); + } + super.addInformation(stack, aPlayer, list, bool); + } + + public final String getMaterialName() { + return materialName; + } + + @Override + public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { + return Utils.rgbtoHexValue(230, 96, 96); + + } +} diff --git a/src/Java/gtPlusPlus/core/item/base/gears/BaseItemGear.java b/src/Java/gtPlusPlus/core/item/base/gears/BaseItemGear.java new file mode 100644 index 0000000000..ba41625b25 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/gears/BaseItemGear.java @@ -0,0 +1,82 @@ +package gtPlusPlus.core.item.base.gears; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.core.util.math.MathUtils; + +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import cpw.mods.fml.common.registry.GameRegistry; + +public class BaseItemGear extends Item{ + + protected int colour; + protected String materialName; + protected String unlocalName; + private int mTier; + + public BaseItemGear(String unlocalizedName, String materialName, int colour, int tier) { + setUnlocalizedName(unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setUnlocalizedName(unlocalizedName); + this.unlocalName = unlocalizedName; + this.setMaxStackSize(64); + this.setTextureName(CORE.MODID + ":" + "itemGear"); + this.colour = colour; + this.mTier = tier; + this.materialName = materialName; + GameRegistry.registerItem(this, unlocalizedName); + GT_OreDictUnificator.registerOre(unlocalName.replace("itemG", "g"), UtilsItems.getSimpleStack(this)); + addExtruderRecipe(); + } + + @Override + public String getItemStackDisplayName(ItemStack p_77653_1_) { + + return (materialName+ " Gear"); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + if (materialName != null && materialName != "" && !materialName.equals("")){ + list.add(EnumChatFormatting.GRAY+"A large Gear, constructed from " + materialName + "."); + } + super.addInformation(stack, aPlayer, list, bool); + } + + public final String getMaterialName() { + return materialName; + } + + @Override + public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { + if (colour == 0){ + return MathUtils.generateSingularRandomHexValue(); + } + return colour; + + } + + private void addExtruderRecipe(){ + Utils.LOG_WARNING("Adding recipe for "+materialName+" Gears"); + String tempIngot = unlocalName.replace("itemGear", "ingot"); + ItemStack tempOutputStack = UtilsItems.getItemStackOfAmountFromOreDict(tempIngot, 8); + if (null != tempOutputStack){ + GT_Values.RA.addExtruderRecipe(tempOutputStack, + ItemList.Shape_Extruder_Gear.get(1), + UtilsItems.getSimpleStack(this), + 40*mTier*20, + 24*mTier); + } + } + +} diff --git a/src/Java/gtPlusPlus/core/item/base/ingots/BaseItemIngot.java b/src/Java/gtPlusPlus/core/item/base/ingots/BaseItemIngot.java new file mode 100644 index 0000000000..e193636043 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/ingots/BaseItemIngot.java @@ -0,0 +1,118 @@ +package gtPlusPlus.core.item.base.ingots; + +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.core.util.math.MathUtils; + +import java.util.List; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; +import cpw.mods.fml.common.registry.GameRegistry; + +public class BaseItemIngot extends Item{ + + protected int colour; + protected String materialName; + protected String unlocalName; + + public BaseItemIngot(String unlocalizedName, String materialName, int colour, int sRadioactivity) { + setUnlocalizedName(unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setUnlocalizedName(unlocalizedName); + this.unlocalName = unlocalizedName; + this.setMaxStackSize(64); + this.setTextureName(CORE.MODID + ":" + "itemIngot"); + this.setMaxStackSize(64); + this.colour = colour; + this.materialName = materialName; + this.sRadiation = sRadioactivity; + GameRegistry.registerItem(this, unlocalizedName); + String temp = ""; + if (unlocalName.contains("itemIngot")){ + temp = unlocalName.replace("itemI", "i"); + } + else if (unlocalName.contains("itemHotIngot")){ + temp = unlocalName.replace("itemHotIngot", "ingotHot"); + } + if (temp != null && temp != ""){ + GT_OreDictUnificator.registerOre(temp, UtilsItems.getSimpleStack(this)); + } + generateCompressorRecipe(); + } + + @Override + public String getItemStackDisplayName(ItemStack p_77653_1_) { + + return (materialName+ " Ingot"); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + if (materialName != null && materialName != "" && !materialName.equals("") && !unlocalName.contains("HotIngot")){ + list.add(EnumChatFormatting.GRAY+"A solid ingot of " + materialName + "."); + } + else if (materialName != null && materialName != "" && !materialName.equals("") && unlocalName.toLowerCase().contains("ingothot")){ + list.add(EnumChatFormatting.GRAY+"Warning: "+EnumChatFormatting.RED+"Very hot! "+EnumChatFormatting.GRAY+" Avoid direct handling.."); + } + if (sRadiation > 0){ + list.add(CORE.GT_Tooltip_Radioactive); + } + super.addInformation(stack, aPlayer, list, bool); + } + + public final String getMaterialName() { + return materialName; + } + + @Override + public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { + if (colour == 0){ + return MathUtils.generateSingularRandomHexValue(); + } + return colour; + + } + + private void generateCompressorRecipe(){ + if (unlocalName.contains("itemIngot")){ + ItemStack tempStack = UtilsItems.getSimpleStack(this, 9); + ItemStack tempOutput = null; + String temp = getUnlocalizedName().replace("item.itemIngot", "block"); + Utils.LOG_WARNING("Unlocalized name for OreDict nameGen: "+getUnlocalizedName()); + if (getUnlocalizedName().contains("item.")){ + temp = getUnlocalizedName().replace("item.", ""); + Utils.LOG_WARNING("Generating OreDict Name: "+temp); + } + temp = temp.replace("itemIngot", "block"); + Utils.LOG_WARNING("Generating OreDict Name: "+temp); + if (temp != null && temp != ""){ + tempOutput = UtilsItems.getItemStackOfAmountFromOreDict(temp, 1); + if (tempOutput != null){ + GT_ModHandler.addCompressionRecipe(tempStack, tempOutput); + } + + } + } + else if (unlocalName.contains("itemHotIngot")){ + return; + } + + + } + + + protected final int sRadiation; + @Override + public void onUpdate(ItemStack iStack, World world, Entity entityHolding, int p_77663_4_, boolean p_77663_5_) { + Utils.applyRadiationDamageToEntity(sRadiation, world, entityHolding); + } +} diff --git a/src/Java/gtPlusPlus/core/item/base/ingots/BaseItemIngotHot.java b/src/Java/gtPlusPlus/core/item/base/ingots/BaseItemIngotHot.java new file mode 100644 index 0000000000..6fa358f36f --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/ingots/BaseItemIngotHot.java @@ -0,0 +1,73 @@ +package gtPlusPlus.core.item.base.ingots; + +import gregtech.api.enums.GT_Values; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.UtilsItems; + +import java.util.List; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.DamageSource; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; + +public class BaseItemIngotHot extends BaseItemIngot{ + + private ItemStack outputIngot; + private int tickCounter = 0; + private int tickCounterMax = 200; + private int mTier; + + public BaseItemIngotHot(String unlocalizedName, String materialName, ItemStack coldIngot, int tier) { + super(unlocalizedName, materialName, Utils.rgbtoHexValue(225, 225, 225), 0); + this.setTextureName(CORE.MODID + ":" + "itemIngotHot"); + this.outputIngot = coldIngot; + this.mTier = tier; + generateRecipe(); + } + + @Override + public String getItemStackDisplayName(ItemStack p_77653_1_) { + + return ("Hot "+materialName+ " Ingot"); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + if (materialName != null && materialName != "" && !materialName.equals("")){ + list.add(EnumChatFormatting.GRAY+"A "+EnumChatFormatting.RED+"burning hot"+EnumChatFormatting.GRAY+" ingot of " + materialName + "."); + } + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { + return Utils.rgbtoHexValue(225, 225, 225); + } + + private void generateRecipe(){ + Utils.LOG_WARNING("Adding Vacuum Freezer recipe for a Hot Ingot of "+materialName+"."); + GT_Values.RA.addVacuumFreezerRecipe(UtilsItems.getSimpleStack(this), outputIngot.copy(), 60*mTier); + + + } + + @Override + public void onUpdate(ItemStack iStack, World world, Entity entityHolding, int p_77663_4_, boolean p_77663_5_) { + if (!world.isRemote){ + if(tickCounter < tickCounterMax){ + tickCounter++; + } + else if(tickCounter == tickCounterMax){ + entityHolding.attackEntityFrom(DamageSource.onFire, 1); + tickCounter = 0; + } + super.onUpdate(iStack, world, entityHolding, p_77663_4_, p_77663_5_); + } + } + + +} diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBase.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBase.java new file mode 100644 index 0000000000..488f9a6f60 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBase.java @@ -0,0 +1,22 @@ +package gtPlusPlus.core.item.base.itemblock; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import net.minecraft.block.Block; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; + +public class ItemBlockBase extends ItemBlock { + + public ItemBlockBase(Block block) { + super(block); + this.setCreativeTab(AddToCreativeTab.tabBlock); + } + + @Override + public int getColorFromItemStack(ItemStack p_82790_1_, int p_82790_2_) { + + return super.getColorFromItemStack(p_82790_1_, p_82790_2_); + } + + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtBlock.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtBlock.java new file mode 100644 index 0000000000..04d01c2c97 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtBlock.java @@ -0,0 +1,51 @@ +package gtPlusPlus.core.item.base.itemblock; + +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.UtilsItems; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public class ItemBlockGtBlock extends ItemBlock{ + + protected final int blockColour; + protected final int sRadiation; + + public ItemBlockGtBlock(Block block) { + super(block); + this.blockColour = block.getBlockColor(); + if (block.getLocalizedName().toLowerCase().contains("uranium") || block.getLocalizedName().toLowerCase().contains("plutonium") || block.getLocalizedName().toLowerCase().contains("thorium")){ + sRadiation = 2; + } + else { + sRadiation = 0; + } + GT_OreDictUnificator.registerOre("block"+block.getUnlocalizedName().replace("tile.block", "").replace("tile.", "").replace("of", "").replace("Of", "").replace("Block", "").replace("-", "").replace("_", "").replace(" ", ""), UtilsItems.getSimpleStack(this)); + } + + public int getRenderColor(int aMeta) { + return blockColour; + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + if (sRadiation > 0){ + list.add(CORE.GT_Tooltip_Radioactive); + } + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + public void onUpdate(ItemStack iStack, World world, Entity entityHolding, int p_77663_4_, boolean p_77663_5_) { + Utils.applyRadiationDamageToEntity(sRadiation, world, entityHolding); + } + +} diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtFrameBox.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtFrameBox.java new file mode 100644 index 0000000000..c8d791b905 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtFrameBox.java @@ -0,0 +1,22 @@ +package gtPlusPlus.core.item.base.itemblock; + +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.util.item.UtilsItems; +import net.minecraft.block.Block; +import net.minecraft.item.ItemBlock; + +public class ItemBlockGtFrameBox extends ItemBlock{ + + protected int blockColour; + + public ItemBlockGtFrameBox(Block block) { + super(block); + this.blockColour = block.getBlockColor(); + GT_OreDictUnificator.registerOre("frameGt"+block.getUnlocalizedName().replace("tile.", "").replace("tile.BlockGtFrame", "").replace("-", "").replace("_", "").replace(" ", "").replace("FrameBox", ""), UtilsItems.getSimpleStack(this)); + } + + public int getRenderColor(int aMeta) { + return blockColour; + } + +} diff --git a/src/Java/gtPlusPlus/core/item/base/plates/BaseItemPlate.java b/src/Java/gtPlusPlus/core/item/base/plates/BaseItemPlate.java new file mode 100644 index 0000000000..9d21198033 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/plates/BaseItemPlate.java @@ -0,0 +1,92 @@ +package gtPlusPlus.core.item.base.plates; + +import gregtech.api.enums.GT_Values; +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.core.util.math.MathUtils; + +import java.util.List; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; +import cpw.mods.fml.common.registry.GameRegistry; + +public class BaseItemPlate extends Item{ + + protected int colour; + protected String materialName; + protected String unlocalName; + private int mTier; + + public BaseItemPlate(String unlocalizedName, String materialName, int colour, int tier, int sRadioactivity) { + setUnlocalizedName(unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setUnlocalizedName(unlocalizedName); + this.unlocalName = unlocalizedName; + this.setMaxStackSize(64); + this.setTextureName(CORE.MODID + ":" + "itemPlate"); + this.colour = colour; + this.mTier = tier; + this.materialName = materialName; + this.sRadiation = sRadioactivity; + GameRegistry.registerItem(this, unlocalizedName); + GT_OreDictUnificator.registerOre(unlocalName.replace("itemP", "p"), UtilsItems.getSimpleStack(this)); + addBendingRecipe(); + } + + @Override + public String getItemStackDisplayName(ItemStack p_77653_1_) { + + return (materialName+ " Plate"); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + if (materialName != null && materialName != "" && !materialName.equals("")){ + list.add(EnumChatFormatting.GRAY+"A flat plate of " + materialName + "."); + } + if (sRadiation > 0){ + list.add(CORE.GT_Tooltip_Radioactive); + } + super.addInformation(stack, aPlayer, list, bool); + } + + public final String getMaterialName() { + return materialName; + } + + @Override + public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { + if (colour == 0){ + return MathUtils.generateSingularRandomHexValue(); + } + return colour; + + } + + protected final int sRadiation; + @Override + public void onUpdate(ItemStack iStack, World world, Entity entityHolding, int p_77663_4_, boolean p_77663_5_) { + Utils.applyRadiationDamageToEntity(sRadiation, world, entityHolding); + } + + private void addBendingRecipe(){ + Utils.LOG_WARNING("Adding recipe for "+materialName+" Plates"); + String tempIngot = unlocalName.replace("itemPlate", "ingot"); + ItemStack tempOutputStack = UtilsItems.getItemStackOfAmountFromOreDict(tempIngot, 1); + if (null != tempOutputStack){ + GT_Values.RA.addBenderRecipe(tempOutputStack, + UtilsItems.getSimpleStack(this), + 14*mTier*20, + 64*mTier); + } + } + +} diff --git a/src/Java/gtPlusPlus/core/item/base/rings/BaseItemRing.java b/src/Java/gtPlusPlus/core/item/base/rings/BaseItemRing.java new file mode 100644 index 0000000000..d5c513c37d --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/rings/BaseItemRing.java @@ -0,0 +1,82 @@ +package gtPlusPlus.core.item.base.rings; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.core.util.math.MathUtils; + +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import cpw.mods.fml.common.registry.GameRegistry; + +public class BaseItemRing extends Item{ + + protected int colour; + protected String materialName; + protected String unlocalName; + private int mTier; + + public BaseItemRing(String unlocalizedName, String materialName, int colour, int tier) { + setUnlocalizedName(unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setUnlocalizedName(unlocalizedName); + this.unlocalName = unlocalizedName; + this.setMaxStackSize(64); + this.setTextureName(CORE.MODID + ":" + "itemRing"); + this.colour = colour; + this.mTier = tier; + this.materialName = materialName; + GameRegistry.registerItem(this, unlocalizedName); + GT_OreDictUnificator.registerOre(unlocalName.replace("itemR", "r"), UtilsItems.getSimpleStack(this)); + addExtruderRecipe(); + } + + @Override + public String getItemStackDisplayName(ItemStack p_77653_1_) { + + return (materialName+ " Ring"); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + if (materialName != null && materialName != "" && !materialName.equals("")){ + list.add(EnumChatFormatting.GRAY+"A " + materialName + " Ring."); + } + super.addInformation(stack, aPlayer, list, bool); + } + + public final String getMaterialName() { + return materialName; + } + + @Override + public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { + if (colour == 0){ + return MathUtils.generateSingularRandomHexValue(); + } + return colour; + + } + + private void addExtruderRecipe(){ + Utils.LOG_WARNING("Adding recipe for "+materialName+" Rings"); + String tempIngot = unlocalName.replace("itemRing", "ingot"); + ItemStack tempOutputStack = UtilsItems.getItemStackOfAmountFromOreDict(tempIngot, 1); + if (null != tempOutputStack){ + GT_Values.RA.addExtruderRecipe(tempOutputStack, + ItemList.Shape_Extruder_Ring.get(1), + UtilsItems.getSimpleStack(this, 4), + 12*mTier*20, + 24*mTier); + } + } + +} diff --git a/src/Java/gtPlusPlus/core/item/base/rods/BaseItemRod.java b/src/Java/gtPlusPlus/core/item/base/rods/BaseItemRod.java new file mode 100644 index 0000000000..befe7552ec --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/rods/BaseItemRod.java @@ -0,0 +1,100 @@ +package gtPlusPlus.core.item.base.rods; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.recipe.UtilsRecipe; + +import java.util.List; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; +import cpw.mods.fml.common.registry.GameRegistry; + +public class BaseItemRod extends Item{ + + protected int colour; + protected String materialName; + protected String unlocalName; + private int mTier; + + public BaseItemRod(String unlocalizedName, String materialName, int colour, int tier, int sRadioactivity) { + setUnlocalizedName(unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setUnlocalizedName(unlocalizedName); + this.unlocalName = unlocalizedName; + this.setTextureName(CORE.MODID + ":" + "itemRod"); + this.setMaxStackSize(64); + this.colour = colour; + this.mTier = tier; + this.materialName = materialName; + this.sRadiation = sRadioactivity; + GameRegistry.registerItem(this, unlocalizedName); + GT_OreDictUnificator.registerOre(unlocalName.replace("itemRod", "stick"), UtilsItems.getSimpleStack(this)); + addExtruderRecipe(); + } + + @Override + public String getItemStackDisplayName(ItemStack p_77653_1_) { + + return (materialName+ " Rod"); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + if (materialName != null && materialName != "" && !materialName.equals("")){ + list.add(EnumChatFormatting.GRAY+"A 40cm Rod of " + materialName + "."); + } + if (sRadiation > 0){ + list.add(CORE.GT_Tooltip_Radioactive); + } + super.addInformation(stack, aPlayer, list, bool); + } + + public final String getMaterialName() { + return materialName; + } + + @Override + public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { + if (colour == 0){ + return MathUtils.generateSingularRandomHexValue(); + } + return colour; + + } + + protected final int sRadiation; + @Override + public void onUpdate(ItemStack iStack, World world, Entity entityHolding, int p_77663_4_, boolean p_77663_5_) { + Utils.applyRadiationDamageToEntity(sRadiation, world, entityHolding); + } + + private void addExtruderRecipe(){ + Utils.LOG_WARNING("Adding recipe for "+materialName+" Rods"); + String tempIngot = unlocalName.replace("itemRod", "ingot"); + ItemStack tempOutputStack = UtilsItems.getItemStackOfAmountFromOreDict(tempIngot, 1); + if (null != tempOutputStack){ + GT_Values.RA.addExtruderRecipe(tempOutputStack, + ItemList.Shape_Extruder_Rod.get(1), + UtilsItems.getSimpleStack(this, 2), + 12*mTier*20, 24*mTier); + } + ItemStack rods = UtilsItems.getSimpleStack(this, 1); + UtilsRecipe.addShapedGregtechRecipe( + rods, rods, rods, + rods, "craftingToolWrench", rods, + rods, rods, rods, + UtilsItems.getItemStackOfAmountFromOreDict(unlocalName.replace("itemRod", "frameGt"), 2)); + } + +} diff --git a/src/Java/gtPlusPlus/core/item/base/rods/BaseItemRodLong.java b/src/Java/gtPlusPlus/core/item/base/rods/BaseItemRodLong.java new file mode 100644 index 0000000000..4e157d22b1 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/rods/BaseItemRodLong.java @@ -0,0 +1,99 @@ +package gtPlusPlus.core.item.base.rods; + +import gregtech.api.enums.GT_Values; +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.recipe.UtilsRecipe; + +import java.util.List; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; +import cpw.mods.fml.common.registry.GameRegistry; + +public class BaseItemRodLong extends Item{ + + protected int colour; + protected String materialName; + protected String unlocalName; + private int mTier; + + public BaseItemRodLong(String unlocalizedName, String materialName, int colour, int tier, int sRadioactivity) { + setUnlocalizedName(unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setUnlocalizedName(unlocalizedName); + this.unlocalName = unlocalizedName; + this.setTextureName(CORE.MODID + ":" + "itemRodLong"); + this.setMaxStackSize(64); + this.colour = colour; + this.mTier = tier; + this.materialName = materialName; + this.sRadiation = sRadioactivity; + GameRegistry.registerItem(this, unlocalizedName); + GT_OreDictUnificator.registerOre(unlocalName.replace("itemRod", "stick"), UtilsItems.getSimpleStack(this)); + addExtruderRecipe(); + } + + @Override + public String getItemStackDisplayName(ItemStack p_77653_1_) { + + return ("Long "+materialName+ " Rod"); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + if (materialName != null && materialName != "" && !materialName.equals("")){ + list.add(EnumChatFormatting.GRAY+"A 80cm Rod of " + materialName + "."); + } + if (sRadiation > 0){ + list.add(CORE.GT_Tooltip_Radioactive); + } + super.addInformation(stack, aPlayer, list, bool); + } + + public final String getMaterialName() { + return materialName; + } + + @Override + public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { + if (colour == 0){ + return MathUtils.generateSingularRandomHexValue(); + } + return colour; + + } + + protected final int sRadiation; + @Override + public void onUpdate(ItemStack iStack, World world, Entity entityHolding, int p_77663_4_, boolean p_77663_5_) { + Utils.applyRadiationDamageToEntity(sRadiation, world, entityHolding); + } + + private void addExtruderRecipe(){ + Utils.LOG_WARNING("Adding recipe for Long "+materialName+" Rods"); + String tempIngot = unlocalName.replace("itemRodLong", "stick"); + ItemStack tempOutputStack = UtilsItems.getItemStackOfAmountFromOreDict(tempIngot, 2); + if (null != tempOutputStack){ + GT_Values.RA.addForgeHammerRecipe(tempOutputStack, + UtilsItems.getSimpleStack(this, 1), + 12*mTier*20, 24*mTier); + } + ItemStack rods = UtilsItems.getSimpleStack(this, 1); + ItemStack tempOutputStack2 = UtilsItems.getItemStackOfAmountFromOreDict(tempIngot, 1); + UtilsRecipe.addShapedGregtechRecipe( + tempOutputStack2, "craftingToolHardHammer", tempOutputStack2, + null, null, null, + null, null, null, + rods); + } + +} diff --git a/src/Java/gtPlusPlus/core/item/base/rotors/BaseItemRotor.java b/src/Java/gtPlusPlus/core/item/base/rotors/BaseItemRotor.java new file mode 100644 index 0000000000..d8ecea32bd --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/rotors/BaseItemRotor.java @@ -0,0 +1,93 @@ +package gtPlusPlus.core.item.base.rotors; + +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.recipe.UtilsRecipe; + +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import cpw.mods.fml.common.registry.GameRegistry; + +public class BaseItemRotor extends Item{ + + protected int colour; + protected String materialName; + protected String unlocalName; + + public BaseItemRotor(String unlocalizedName, String materialName, int colour) { + setUnlocalizedName(unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setUnlocalizedName(unlocalizedName); + this.unlocalName = unlocalizedName; + this.setMaxStackSize(64); + this.setTextureName(CORE.MODID + ":" + "itemRotor"); + this.colour = colour; + this.materialName = materialName; + GameRegistry.registerItem(this, unlocalizedName); + GT_OreDictUnificator.registerOre(unlocalName.replace("itemR", "r"), UtilsItems.getSimpleStack(this)); + generateRecipe(); + } + + @Override + public String getItemStackDisplayName(ItemStack p_77653_1_) { + + return (materialName+ " Rotor"); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + if (materialName != null && materialName != "" && !materialName.equals("")){ + list.add(EnumChatFormatting.GRAY+"A spindley Rotor made out of " + materialName + ". "); + } + super.addInformation(stack, aPlayer, list, bool); + } + + public final String getMaterialName() { + return materialName; + } + + @Override + public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { + if (colour == 0){ + return MathUtils.generateSingularRandomHexValue(); + } + return colour; + + } + + public static boolean getValidItemStack(ItemStack validStack){ + if (validStack != null){ + return true; + } + return false; + } + + public void generateRecipe(){ + + Utils.LOG_WARNING("Adding recipe for "+materialName+" Rotors"); + String tempIngot = unlocalName.replace("itemRotor", "plate"); + ItemStack tempOutputStack = UtilsItems.getItemStackOfAmountFromOreDict(tempIngot, 1); + Utils.LOG_WARNING("Found for recipe:"+tempIngot+ "isValidStack()="+getValidItemStack(tempOutputStack)); + String screw = unlocalName.replace("itemRotor", "screw"); + ItemStack screwStack = UtilsItems.getItemStackOfAmountFromOreDict(screw, 1); + Utils.LOG_WARNING("Found for recipe:"+screw+ "isValidStack()="+getValidItemStack(screwStack)); + String ring = unlocalName.replace("itemRotor", "ring"); + ItemStack ringStack = UtilsItems.getItemStackOfAmountFromOreDict(ring, 1); + Utils.LOG_WARNING("Found for recipe:"+ring+ "isValidStack()="+getValidItemStack(ringStack)); + + UtilsRecipe.addShapedGregtechRecipe( + tempOutputStack, "craftingToolHardHammer", tempOutputStack, + screwStack, ringStack, "craftingToolFile", + tempOutputStack, "craftingToolScrewdriver", tempOutputStack, + UtilsItems.getSimpleStack(this)); + } + +} diff --git a/src/Java/gtPlusPlus/core/item/base/screws/BaseItemScrew.java b/src/Java/gtPlusPlus/core/item/base/screws/BaseItemScrew.java new file mode 100644 index 0000000000..953c3a99a3 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/screws/BaseItemScrew.java @@ -0,0 +1,85 @@ +package gtPlusPlus.core.item.base.screws; + +import gregtech.api.enums.GT_Values; +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.recipe.UtilsRecipe; + +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import cpw.mods.fml.common.registry.GameRegistry; + +public class BaseItemScrew extends Item{ + + protected int colour; + protected String materialName; + protected String unlocalName; + private int mTier; + + public BaseItemScrew(String unlocalizedName, String materialName, int colour, int tier) { + setUnlocalizedName(unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setUnlocalizedName(unlocalizedName); + this.unlocalName = unlocalizedName; + this.setMaxStackSize(64); + this.setTextureName(CORE.MODID + ":" + "itemScrew"); + this.setMaxStackSize(64); + this.colour = colour; + this.mTier = tier; + this.materialName = materialName; + GameRegistry.registerItem(this, unlocalizedName); + GT_OreDictUnificator.registerOre(unlocalName.replace("itemS", "s"), UtilsItems.getSimpleStack(this)); + addLatheRecipe(); + } + + @Override + public String getItemStackDisplayName(ItemStack p_77653_1_) { + + return (materialName+ " Screw"); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + if (materialName != null && materialName != "" && !materialName.equals("")){ + list.add(EnumChatFormatting.GRAY+"A 8mm Screw, fabricated out of some " + materialName + "."); + } + super.addInformation(stack, aPlayer, list, bool); + } + + public final String getMaterialName() { + return materialName; + } + + @Override + public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { + if (colour == 0){ + return MathUtils.generateSingularRandomHexValue(); + } + return colour; + + } + + private void addLatheRecipe(){ + Utils.LOG_WARNING("Adding recipe for "+materialName+" Screws"); + ItemStack boltStack = UtilsItems.getItemStackOfAmountFromOreDict(unlocalName.replace("itemScrew", "bolt"), 1); + if (null != boltStack){ + GT_Values.RA.addLatheRecipe(boltStack, + UtilsItems.getSimpleStack(this), null, + 60*mTier, 16*mTier); + UtilsRecipe.addShapedGregtechRecipe( + "craftingToolFile", boltStack, null, + boltStack, null, null, + null, null, null, + UtilsItems.getSimpleStack(this)); + } + } + +} |
