aboutsummaryrefslogtreecommitdiff
path: root/src/Java/miscutil/core/item
diff options
context:
space:
mode:
authorDraknyte1 <Draknyte1@hotmail.com>2016-07-18 04:54:59 +1000
committerDraknyte1 <Draknyte1@hotmail.com>2016-07-18 04:54:59 +1000
commit99f319880374db0c20d43b8c557c777ec1f8e998 (patch)
treea8c36027c5ea54f66dfd75d6cdc6dbb59fa33ebb /src/Java/miscutil/core/item
parent3967b8155fad9767517415fcac5082b2a520ce7a (diff)
downloadGT5-Unofficial-99f319880374db0c20d43b8c557c777ec1f8e998.tar.gz
GT5-Unofficial-99f319880374db0c20d43b8c557c777ec1f8e998.tar.bz2
GT5-Unofficial-99f319880374db0c20d43b8c557c777ec1f8e998.zip
+ Added Custom spawn eggs.
% More stuff added to Utils.java
Diffstat (limited to 'src/Java/miscutil/core/item')
-rw-r--r--src/Java/miscutil/core/item/ModItems.java28
-rw-r--r--src/Java/miscutil/core/item/base/BasicSpawnEgg.java258
2 files changed, 277 insertions, 9 deletions
diff --git a/src/Java/miscutil/core/item/ModItems.java b/src/Java/miscutil/core/item/ModItems.java
index b02cc79676..566a90015e 100644
--- a/src/Java/miscutil/core/item/ModItems.java
+++ b/src/Java/miscutil/core/item/ModItems.java
@@ -14,6 +14,7 @@ import miscutil.core.lib.CORE;
import miscutil.core.lib.LoadedMods;
import miscutil.core.util.Utils;
import miscutil.core.util.debug.DEBUG_INIT;
+import miscutil.core.util.item.UtilsItems;
import net.minecraft.item.Item;
import net.minecraft.item.Item.ToolMaterial;
import net.minecraftforge.common.util.EnumHelper;
@@ -57,9 +58,11 @@ Gold Tool: 22*/
//Tool Materials
//public static ToolMaterial TUTORIAL = EnumHelper.addToolMaterial("TUTORIAL", harvestLevel, durability, miningSpeed, damageVsEntities, enchantability);
public static ToolMaterial STABALLOY = EnumHelper.addToolMaterial("Staballoy", 3, 2500, 7, 1.0F, 18);
-
+
public static Item itemDebugShapeSpawner;
-
+
+ public static Item itemBaseSpawnEgg;
+
//EnderIO
public static Item itemPlateSoularium;
public static Item itemPlateRedstoneAlloy;
@@ -101,18 +104,18 @@ Gold Tool: 22*/
public static Item itemPlateBatteryAlloy;
public static Item itemHeliumBlob;
public static Item itemPLACEHOLDER_Circuit;
-
+
public static Item FuelRod_Empty;
public static Item FuelRod_Thorium;
public static Item FuelRod_Uranium;
public static Item FuelRod_Plutonium;
-
+
public static Item itemBedLocator_Base;
public static Item itemBaseItemWithCharge;
-
+
//@SuppressWarnings("unused")
public static final void init(){
-
+
//Debug Loading
if (CORE.DEBUG){
DEBUG_INIT.registerItems();
@@ -238,10 +241,17 @@ Gold Tool: 22*/
else {
Utils.LOG_WARNING("IndustrialCraft2 not Found - Skipping Resources.");
}
+
+
+
+ UtilsItems.generateSpawnEgg("minecraft", "villager", Utils.generateSingularRandomHexValue(), Utils.generateSingularRandomHexValue());
+
+
+
/*
* Misc Items
*/
-
+
//Staballoy Equipment
itemStaballoyPickaxe = new StaballoyPickaxe("itemStaballoyPickaxe", STABALLOY).setCreativeTab(AddToCreativeTab.tabTools);
GameRegistry.registerItem(itemStaballoyPickaxe, itemStaballoyPickaxe.getUnlocalizedName());
@@ -275,10 +285,10 @@ Gold Tool: 22*/
GameRegistry.registerItem(itemIngotBatteryAlloy, "itemIngotBatteryAlloy");
itemPlateBatteryAlloy = new Item().setUnlocalizedName("itemPlateBatteryAlloy").setCreativeTab(tabMachines).setTextureName(CORE.MODID + ":itemPlateBatteryAlloy");
GameRegistry.registerItem(itemPlateBatteryAlloy, "itemPlateBatteryAlloy");
-
+
itemHeliumBlob = new CoreItem("itemHeliumBlob", tabMisc).setTextureName(CORE.MODID + ":itemHeliumBlob");
//GameRegistry.registerItem(itemHeliumBlob, "itemHeliumBlob");
-
+
itemPLACEHOLDER_Circuit = new Item().setUnlocalizedName("itemPLACEHOLDER_Circuit").setTextureName(CORE.MODID + ":itemPLACEHOLDER_Circuit");
GameRegistry.registerItem(itemPLACEHOLDER_Circuit, "itemPLACEHOLDER_Circuit");
//Try some New Tools from GT
diff --git a/src/Java/miscutil/core/item/base/BasicSpawnEgg.java b/src/Java/miscutil/core/item/base/BasicSpawnEgg.java
new file mode 100644
index 0000000000..fd80fab854
--- /dev/null
+++ b/src/Java/miscutil/core/item/base/BasicSpawnEgg.java
@@ -0,0 +1,258 @@
+package miscutil.core.item.base;
+
+
+import java.util.List;
+
+import miscutil.core.creative.AddToCreativeTab;
+import miscutil.core.util.Utils;
+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;
+ }
+
+}
+