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("")){ |
