diff options
author | Alkalus <Draknyte1@hotmail.com> | 2020-05-04 01:32:46 +0100 |
---|---|---|
committer | Alkalus <Draknyte1@hotmail.com> | 2020-05-04 01:32:46 +0100 |
commit | 2b7ae2001ed8f49d2de8f88ef306426af60c279b (patch) | |
tree | 954737087b6adcbb4b3b8f4f7d3464d2e0212b6f /src | |
parent | 3159aef00e7babcf8c5e1d574a738b6d2cac9e42 (diff) | |
download | GT5-Unofficial-2b7ae2001ed8f49d2de8f88ef306426af60c279b.tar.gz GT5-Unofficial-2b7ae2001ed8f49d2de8f88ef306426af60c279b.tar.bz2 GT5-Unofficial-2b7ae2001ed8f49d2de8f88ef306426af60c279b.zip |
$ Fixed handling of Giant Eggs.
$ Fixed obscure crash caused by Dingos.
$ Fixed handling of Spawn Eggs and entities registered to the global list.
$ Potentially fixed NEI not working correctly for GT++ recipe maps.
Diffstat (limited to 'src')
29 files changed, 1682 insertions, 299 deletions
diff --git a/src/Java/gtPlusPlus/GTplusplus.java b/src/Java/gtPlusPlus/GTplusplus.java index 1bf67c15fc..f138d5f95d 100644 --- a/src/Java/gtPlusPlus/GTplusplus.java +++ b/src/Java/gtPlusPlus/GTplusplus.java @@ -32,6 +32,8 @@ import gtPlusPlus.core.handler.Recipes.RegistrationHandler; import gtPlusPlus.core.handler.events.BlockEventHandler; import gtPlusPlus.core.handler.events.LoginEventHandler; import gtPlusPlus.core.handler.events.MissingMappingsEvent; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.item.general.ItemGiantEgg; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.material.Material; @@ -196,6 +198,7 @@ public class GTplusplus implements ActionListener { Core_Manager.postInit(); //SprinklerHandler.registerModFerts(); + ItemGiantEgg.postInit(ModItems.itemBigEgg); BlockEventHandler.init(); GTPP_Recipe.reInit(); diff --git a/src/Java/gtPlusPlus/australia/entity/type/EntityDingo.java b/src/Java/gtPlusPlus/australia/entity/type/EntityDingo.java index 02068411fc..11b9737c4f 100644 --- a/src/Java/gtPlusPlus/australia/entity/type/EntityDingo.java +++ b/src/Java/gtPlusPlus/australia/entity/type/EntityDingo.java @@ -113,9 +113,6 @@ public class EntityDingo extends EntityWolf { protected void entityInit() { super.entityInit(); - this.dataWatcher.addObject(18, new Float(this.getHealth())); - this.dataWatcher.addObject(19, new Byte((byte) 0)); - this.dataWatcher.addObject(20, new Byte((byte) BlockColored.func_150032_b(1))); } protected void func_145780_a(int p_145780_1_, int p_145780_2_, int p_145780_3_, Block p_145780_4_) { @@ -127,8 +124,6 @@ public class EntityDingo extends EntityWolf { */ public void writeEntityToNBT(NBTTagCompound p_70014_1_) { super.writeEntityToNBT(p_70014_1_); - p_70014_1_.setBoolean("Angry", this.isAngry()); - p_70014_1_.setByte("CollarColor", (byte) this.getCollarColor()); } /** @@ -136,11 +131,6 @@ public class EntityDingo extends EntityWolf { */ public void readEntityFromNBT(NBTTagCompound p_70037_1_) { super.readEntityFromNBT(p_70037_1_); - this.setAngry(p_70037_1_.getBoolean("Angry")); - - if (p_70037_1_.hasKey("CollarColor", 99)) { - this.setCollarColor(p_70037_1_.getByte("CollarColor")); - } } /** diff --git a/src/Java/gtPlusPlus/core/block/ModBlocks.java b/src/Java/gtPlusPlus/core/block/ModBlocks.java index a8536683b5..d5bf2da25d 100644 --- a/src/Java/gtPlusPlus/core/block/ModBlocks.java +++ b/src/Java/gtPlusPlus/core/block/ModBlocks.java @@ -13,19 +13,7 @@ import gtPlusPlus.core.block.general.PlayerDoors; import gtPlusPlus.core.block.general.antigrief.BlockWitherProof; import gtPlusPlus.core.block.general.redstone.BlockGenericRedstoneDetector; import gtPlusPlus.core.block.general.redstone.BlockGenericRedstoneTest; -import gtPlusPlus.core.block.machine.CircuitProgrammer; -import gtPlusPlus.core.block.machine.DecayablesChest; -import gtPlusPlus.core.block.machine.FishTrap; -import gtPlusPlus.core.block.machine.HeliumGenerator; -import gtPlusPlus.core.block.machine.Machine_ModularityTable; -import gtPlusPlus.core.block.machine.Machine_PestKiller; -import gtPlusPlus.core.block.machine.Machine_PooCollector; -import gtPlusPlus.core.block.machine.Machine_ProjectTable; -import gtPlusPlus.core.block.machine.Machine_RoundRobinator; -import gtPlusPlus.core.block.machine.Machine_SuperJukebox; -import gtPlusPlus.core.block.machine.Machine_TradeTable; -import gtPlusPlus.core.block.machine.Machine_Workbench; -import gtPlusPlus.core.block.machine.Machine_WorkbenchAdvanced; +import gtPlusPlus.core.block.machine.*; import gtPlusPlus.core.block.machine.bedrock.Mining_Head_Fake; import gtPlusPlus.core.block.machine.bedrock.Mining_Pipe_Fake; import gtPlusPlus.core.fluids.FluidRegistryHandler; @@ -44,6 +32,7 @@ public final class ModBlocks { public static Block blockWorkbench; public static Block blockWorkbenchAdvanced; public static Block blockDecayablesChest; + public static Block blockEggBox; //Blocks //public static Block blockBloodSteel; @@ -137,8 +126,9 @@ public final class ModBlocks { blockFakeMiningHead = new Mining_Head_Fake(); blockCircuitProgrammer = new CircuitProgrammer(); - + blockDecayablesChest = new DecayablesChest(); + blockEggBox = new EggBox(); blockPlayerDoorWooden = new PlayerDoors(Material.wood, "door_wood", true); blockPlayerDoorIron = new PlayerDoors(Material.iron, "door_iron", true); diff --git a/src/Java/gtPlusPlus/core/block/machine/EggBox.java b/src/Java/gtPlusPlus/core/block/machine/EggBox.java new file mode 100644 index 0000000000..f36dc83704 --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/machine/EggBox.java @@ -0,0 +1,175 @@ +package gtPlusPlus.core.block.machine; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.LanguageRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.GTplusplus; +import gtPlusPlus.api.interfaces.ITileTooltip; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.handler.GuiHandler; +import gtPlusPlus.core.item.base.itemblock.ItemBlockBasicTile; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.tileentities.general.TileEntityEggBox; +import gtPlusPlus.core.util.minecraft.InventoryUtils; +import net.minecraft.block.Block; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class EggBox extends BlockContainer implements ITileTooltip +{ + @SideOnly(Side.CLIENT) + private IIcon textureTop; + @SideOnly(Side.CLIENT) + private IIcon textureBottom; + @SideOnly(Side.CLIENT) + private IIcon textureFront; + + /** + * Determines which tooltip is displayed within the itemblock. + */ + private final int mTooltipID = 5; + public final int field_149956_a = 0; + + @Override + public int getTooltipID() { + return this.mTooltipID; + } + + @SuppressWarnings("deprecation") + public EggBox(){ + super(Material.wood); + this.setBlockName("blockEggBox"); + this.setCreativeTab(AddToCreativeTab.tabMachines); + this.setHardness(5f); + this.setResistance(1f); + GameRegistry.registerBlock(this, ItemBlockBasicTile.class, "blockEggBox"); + LanguageRegistry.addName(this, "Egg Box"); + + } + + /** + * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc) + */ + public boolean renderAsNormalBlock() + { + return true; + } + + /** + * The type of render function that is called for this block + */ + @SideOnly(Side.CLIENT) + public int getRenderType(){ + return super.getRenderType(); + } + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int p_149691_1_, final int p_149691_2_) + { + return p_149691_1_ == 1 ? this.textureTop : this.textureFront; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister p_149651_1_) + { + this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "EggBox_top"); + this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "EggBox_top"); + this.textureBottom = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "EggBox_side"); + this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "EggBox_side"); + } + + /** + * Called upon block activation (right click on the block.) + */ + @Override + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float lx, final float ly, final float lz) + { + if (world.isRemote) { + return true; + } + + final TileEntity te = world.getTileEntity(x, y, z); + if ((te != null) && (te instanceof TileEntityEggBox)){ + player.openGui(GTplusplus.instance, GuiHandler.GUI17, world, x, y, z); + return true; + } + return false; + } + + @Override + public int getRenderBlockPass() { + return 0; + } + + @Override + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { + return new TileEntityEggBox(); + } + + @Override + public void onBlockAdded(final World world, final int x, final int y, final int z) { + super.onBlockAdded(world, x, y, z); + } + + @Override + public void breakBlock(final World world, final int x, final int y, final int z, final Block block, final int number) { + InventoryUtils.dropInventoryItems(world, x, y, z, block); + super.breakBlock(world, x, y, z, block, number); + } + + @Override + public void onBlockPlacedBy(final World world, final int x, final int y, final int z, final EntityLivingBase entity, final ItemStack stack) { + if (stack.hasDisplayName()) { + ((TileEntityEggBox) world.getTileEntity(x,y,z)).setCustomName(stack.getDisplayName()); + } + } + + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + + /*@Override + public void breakBlock(World world, BlockPos pos, IBlockState blockstate) { + TileEntityFishTrap te = (TileEntityFishTrap) world.getTileEntity(pos); + InventoryHelper.dropInventoryItems(world, pos, te); + super.breakBlock(world, pos, blockstate); + } + + + @Override + public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { + if (stack.hasDisplayName()) { + ((TileEntityFishTrap) worldIn.getTileEntity(pos)).setCustomName(stack.getDisplayName()); + } + }*/ + + /** + * Update Chest Meta - Stub + * @param aWorld + * @param xPos + * @param yPos + * @param zPos + */ + @Deprecated + public void func_149954_e(World aWorld, int xPos, int yPos, int zPos) + { + + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/client/model/ModelEggBox.java b/src/Java/gtPlusPlus/core/client/model/ModelEggBox.java new file mode 100644 index 0000000000..0aef4eb7b0 --- /dev/null +++ b/src/Java/gtPlusPlus/core/client/model/ModelEggBox.java @@ -0,0 +1,65 @@ +package gtPlusPlus.core.client.model; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.data.Pair; +import gtPlusPlus.core.client.model.tabula.ModelTabulaBase; +import gtPlusPlus.core.client.renderer.tabula.RenderTabulaBase; +import gtPlusPlus.core.tileentities.general.TileEntityEggBox; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.entity.Entity; + +/** + * ModelEggBox - Alkalus + * Created using Tabula 4.1.1 + */ +public class ModelEggBox extends ModelTabulaBase { + + private final AutoMap<Pair<ModelRenderer, Float>> mParts = new AutoMap<Pair<ModelRenderer, Float>>(); + + private static RenderTabulaBase mRendererInstance; + + public ModelRenderer bottom; + //EggBox_full.png + + public ModelEggBox() { + super(64, 64); + this.textureWidth = 64; + this.textureHeight = 64; + + this.bottom = new ModelRenderer(this, 0, 19); + this.bottom.setRotationPoint(1.0F, 6.0F, 1.0F); + this.bottom.addBox(0.0F, 0.0F, 0.0F, 14, 10, 14, 0.0F); + mParts.add(new Pair<ModelRenderer, Float>(bottom, 0f)); + } + + @Override + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + //Logger.INFO("Rendering EggBox"); + this.bottom.render(f5); + } + + /** + * This is a helper function from Tabula to set the rotation of model parts + */ + public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) { + modelRenderer.rotateAngleX = x; + modelRenderer.rotateAngleY = y; + modelRenderer.rotateAngleZ = z; + } + + @Override + protected AutoMap<Pair<ModelRenderer, Float>> getModelParts() { + AutoMap<Pair<ModelRenderer, Float>> aParts = new AutoMap<Pair<ModelRenderer, Float>>(); + aParts.add(new Pair<ModelRenderer, Float>(bottom, 0.0625F)); + return aParts; + //return mParts; + } + + public static RenderTabulaBase getRenderer() { + if (mRendererInstance == null) { + mRendererInstance = new RenderTabulaBase(new ModelEggBox(), "textures/blocks/TileEntities/EggBox_full.png", TileEntityEggBox.class); + } + return mRendererInstance; + } +} diff --git a/src/Java/gtPlusPlus/core/client/model/tabula/ModelTabulaBase.java b/src/Java/gtPlusPlus/core/client/model/tabula/ModelTabulaBase.java new file mode 100644 index 0000000000..3a0cbb636b --- /dev/null +++ b/src/Java/gtPlusPlus/core/client/model/tabula/ModelTabulaBase.java @@ -0,0 +1,38 @@ +package gtPlusPlus.core.client.model.tabula; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.data.Pair; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; + +/** + * ModelEggBox - Alkalus + * Created using Tabula 4.1.1 + */ +public abstract class ModelTabulaBase extends ModelBase { + + + public ModelTabulaBase(int aTexWidth, int aTexHeight) { + this.textureWidth = aTexWidth; + this.textureHeight = aTexHeight; + } + + protected abstract AutoMap<Pair<ModelRenderer, Float>> getModelParts(); + + public void renderAll() { + for (Pair<ModelRenderer, Float> part : getModelParts()) { + //Logger.INFO("Rendering EggBox"); + part.getKey().render(part.getValue()); + } + } + + /** + * This is a helper function from Tabula to set the rotation of model parts + */ + public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) { + modelRenderer.rotateAngleX = x; + modelRenderer.rotateAngleY = y; + modelRenderer.rotateAngleZ = z; + } +} diff --git a/src/Java/gtPlusPlus/core/client/renderer/tabula/RenderTabulaBase.java b/src/Java/gtPlusPlus/core/client/renderer/tabula/RenderTabulaBase.java new file mode 100644 index 0000000000..b4f64f9b35 --- /dev/null +++ b/src/Java/gtPlusPlus/core/client/renderer/tabula/RenderTabulaBase.java @@ -0,0 +1,46 @@ +package gtPlusPlus.core.client.renderer.tabula; + +import cpw.mods.fml.client.registry.RenderingRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.client.model.tabula.ModelTabulaBase; +import gtPlusPlus.core.lib.CORE; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; + +@SideOnly(Side.CLIENT) +public class RenderTabulaBase extends TileEntitySpecialRenderer { + + private final ModelTabulaBase mModel; + private final ResourceLocation mTexture; + private final Class mTileClass; + + public final int mRenderID; + public final RenderTabulaBase mInstance; + + public RenderTabulaBase(ModelTabulaBase aModel, String aTexturePath, Class aTileClass) { + mModel = aModel; + mTexture = new ResourceLocation(CORE.MODID, aTexturePath); + mTileClass = aTileClass; + this.mRenderID = RenderingRegistry.getNextAvailableRenderId(); + mInstance = this; + } + + public void renderTileEntityAt(Object aTile, double p_147500_2_, double p_147500_4_, double p_147500_6_, float p_147500_8_) { + if (mTileClass.isInstance(aTile)) { + //Logger.INFO("Rendering EggBox"); + this.bindTexture(mTexture); + mModel.renderAll(); + } + } + + public void renderTileEntityAt(TileEntity aTile, double p_147500_2_, double p_147500_4_, double p_147500_6_, float p_147500_8_) { + if (mTileClass != null && aTile != null) { + if (mTileClass.isInstance(aTile)) { + this.renderTileEntityAt((Object) aTile, p_147500_2_, p_147500_4_, p_147500_6_, p_147500_8_); + } + } + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/container/Container_DecayablesChest.java b/src/Java/gtPlusPlus/core/container/Container_DecayablesChest.java index dfb9bb7298..5bc384cd29 100644 --- a/src/Java/gtPlusPlus/core/container/Container_DecayablesChest.java +++ b/src/Java/gtPlusPlus/core/container/Container_DecayablesChest.java @@ -1,5 +1,8 @@ package gtPlusPlus.core.container; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.inventories.Inventory_DecayablesChest; +import gtPlusPlus.core.tileentities.general.TileEntityDecayablesChest; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; @@ -7,12 +10,6 @@ import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.inventories.Inventory_DecayablesChest; -import gtPlusPlus.core.slots.SlotNoInput; -import gtPlusPlus.core.tileentities.general.TileEntityDecayablesChest; -import gtPlusPlus.core.tileentities.general.TileEntityFishTrap; - public class Container_DecayablesChest extends Container { protected TileEntityDecayablesChest tile_entity; diff --git a/src/Java/gtPlusPlus/core/container/Container_EggBox.java b/src/Java/gtPlusPlus/core/container/Container_EggBox.java new file mode 100644 index 0000000000..c4396cca6f --- /dev/null +++ b/src/Java/gtPlusPlus/core/container/Container_EggBox.java @@ -0,0 +1,140 @@ +package gtPlusPlus.core.container; + +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.inventories.Inventory_EggBox; +import gtPlusPlus.core.tileentities.general.TileEntityEggBox; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public class Container_EggBox extends Container { + + protected TileEntityEggBox tile_entity; + public final Inventory_EggBox inventoryChest; + + private final World worldObj; + private final int posX; + private final int posY; + private final int posZ; + + public static int StorageSlotNumber = 15; // Number of slots in storage area + public static int InventorySlotNumber = 36; // Inventory Slots (Inventory + // and Hotbar) + public static int FullSlotNumber = InventorySlotNumber + StorageSlotNumber; // All + // slots + + private final int[] slotStorage = new int[15]; + + public Container_EggBox(final InventoryPlayer inventory, final TileEntityEggBox te) { + this.tile_entity = te; + this.inventoryChest = te.getInventory(); + te.openInventory(); + + int var6; + int var7; + this.worldObj = te.getWorldObj(); + this.posX = te.xCoord; + this.posY = te.yCoord; + this.posZ = te.zCoord; + + int o = 0; + + // Storage Side + for (var6 = 0; var6 < 3; var6++) { + for (var7 = 0; var7 < 5; var7++) { + this.slotStorage[o] = o; + this.addSlotToContainer(new Slot(this.inventoryChest, o++, 44 + (var7 * 18), 15 + (var6 * 18))); + } + } + + // Player Inventory + for (var6 = 0; var6 < 3; ++var6) { + for (var7 = 0; var7 < 9; ++var7) { + this.addSlotToContainer(new Slot(inventory, var7 + (var6 * 9) + 9, 8 + (var7 * 18), 84 + (var6 * 18))); + } + } + + // Player Hotbar + for (var6 = 0; var6 < 9; ++var6) { + this.addSlotToContainer(new Slot(inventory, var6, 8 + (var6 * 18), 142)); + } + + } + + @Override + public ItemStack slotClick(final int aSlotIndex, final int aMouseclick, final int aShifthold, + final EntityPlayer aPlayer) { + + if (!aPlayer.worldObj.isRemote) { + if ((aSlotIndex == 999) || (aSlotIndex == -999)) { + // Utils.LOG_WARNING("??? - "+aSlotIndex); + } + } + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + + @Override + public void onContainerClosed(final EntityPlayer par1EntityPlayer) { + super.onContainerClosed(par1EntityPlayer); + tile_entity.closeInventory(); + } + + @Override + public boolean canInteractWith(final EntityPlayer par1EntityPlayer) { + if (this.worldObj.getBlock(this.posX, this.posY, this.posZ) != ModBlocks.blockEggBox) { + return false; + } + + return par1EntityPlayer.getDistanceSq(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D) <= 64D; + } + + @Override + public ItemStack transferStackInSlot(final EntityPlayer par1EntityPlayer, final int par2) { + ItemStack var3 = null; + final Slot var4 = (Slot) this.inventorySlots.get(par2); + + if ((var4 != null) && var4.getHasStack()) { + final ItemStack var5 = var4.getStack(); + var3 = var5.copy(); + + /* + * if (par2 == 0) { if (!this.mergeItemStack(var5, + * InOutputSlotNumber, FullSlotNumber, true)) { return null; } + * + * var4.onSlotChange(var5, var3); } else if (par2 >= + * InOutputSlotNumber && par2 < InventoryOutSlotNumber) { if + * (!this.mergeItemStack(var5, InventoryOutSlotNumber, + * FullSlotNumber, false)) { return null; } } else if (par2 >= + * InventoryOutSlotNumber && par2 < FullSlotNumber) { if + * (!this.mergeItemStack(var5, InOutputSlotNumber, + * InventoryOutSlotNumber, false)) { return null; } } else if + * (!this.mergeItemStack(var5, InOutputSlotNumber, FullSlotNumber, + * false)) { return null; } + */ + + if (var5.stackSize == 0) { + var4.putStack((ItemStack) null); + } else { + var4.onSlotChanged(); + } + + if (var5.stackSize == var3.stackSize) { + return null; + } + + var4.onPickupFromSlot(par1EntityPlayer, var5); + } + + return var3; + } + + // Can merge Slot + @Override + public boolean func_94530_a(final ItemStack p_94530_1_, final Slot p_94530_2_) { + return super.func_94530_a(p_94530_1_, p_94530_2_); + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/entity/InternalEntityRegistry.java b/src/Java/gtPlusPlus/core/entity/InternalEntityRegistry.java index aec82119cc..6b88d5775c 100644 --- a/src/Java/gtPlusPlus/core/entity/InternalEntityRegistry.java +++ b/src/Java/gtPlusPlus/core/entity/InternalEntityRegistry.java @@ -17,6 +17,7 @@ import gtPlusPlus.core.entity.projectile.EntityLightningAttack; import gtPlusPlus.core.entity.projectile.EntitySulfuricAcidPotion; import gtPlusPlus.core.entity.projectile.EntityThrowableBomb; import gtPlusPlus.core.entity.projectile.EntityToxinballSmall; +import gtPlusPlus.core.item.general.spawn.ItemCustomSpawnEgg; import gtPlusPlus.core.util.Utils; public class InternalEntityRegistry { @@ -28,7 +29,6 @@ public class InternalEntityRegistry { //EntityRegistry.registerGlobalEntityID(EntityPrimedMiningExplosive.class, "MiningCharge", EntityRegistry.findGlobalUniqueEntityId(), Utils.rgbtoHexValue(0, 0, 0), Utils.rgbtoHexValue(125, 125, 125)); EntityRegistry.registerModEntity(EntityPrimedMiningExplosive.class, "MiningCharge", mEntityID++, GTplusplus.instance, 64, 20, true); - //EntityRegistry.registerGlobalEntityID(EntitySulfuricAcidPotion.class, "throwablePotionSulfuric", EntityRegistry.findGlobalUniqueEntityId(), Utils.rgbtoHexValue(200, 0, 200), Utils.rgbtoHexValue(125, 125, 125)); EntityRegistry.registerModEntity(EntitySulfuricAcidPotion.class, "throwablePotionSulfuric", mEntityID++, GTplusplus.instance, 64, 20, true); @@ -44,11 +44,11 @@ public class InternalEntityRegistry { //EntityRegistry.registerGlobalEntityID(EntityStaballoyConstruct.class, "constructStaballoy", EntityRegistry.findGlobalUniqueEntityId(), Utils.rgbtoHexValue(0, 75, 0), Utils.rgbtoHexValue(50, 220, 50)); EntityRegistry.registerModEntity(EntityStaballoyConstruct.class, "constructStaballoy", mEntityID++, GTplusplus.instance, 64, 20, true); - + ItemCustomSpawnEgg.registerEntityForSpawnEgg(0, "constructStaballoy", Utils.rgbtoHexValue(20, 200, 20), Utils.rgbtoHexValue(20, 20, 20)); //EntityRegistry.registerGlobalEntityID(EntitySickBlaze.class, "sickBlaze", EntityRegistry.findGlobalUniqueEntityId(), Utils.rgbtoHexValue(0, 75, 0), Utils.rgbtoHexValue(75, 175, 75)); EntityRegistry.registerModEntity(EntitySickBlaze.class, "sickBlaze", mEntityID++, GTplusplus.instance, 64, 20, true); - + ItemCustomSpawnEgg.registerEntityForSpawnEgg(1, "sickBlaze", Utils.rgbtoHexValue(40, 180, 40), Utils.rgbtoHexValue(75, 75, 75)); //EntityRegistry.registerGlobalEntityID(EntityTeslaTowerLightning.class, "plasmaBolt", EntityRegistry.findGlobalUniqueEntityId(), Utils.rgbtoHexValue(255, 0, 0), Utils.rgbtoHexValue(125, 125, 125)); EntityRegistry.registerModEntity(EntityTeslaTowerLightning.class, "plasmaBolt", mEntityID++, GTplusplus.instance, 64, 5, true); @@ -61,8 +61,10 @@ public class InternalEntityRegistry { * Globals, which generate spawn eggs. (Currently required for Giant chicken spawning) */ - EntityRegistry.registerGlobalEntityID(EntityGiantChickenBase.class, "bigChickenFriendly", EntityRegistry.findGlobalUniqueEntityId(), Utils.rgbtoHexValue(255, 0, 0), Utils.rgbtoHexValue(175, 175, 175)); - EntityRegistry.registerGlobalEntityID(EntityBatKing.class, "batKing", EntityRegistry.findGlobalUniqueEntityId(), Utils.rgbtoHexValue(175, 175, 0), Utils.rgbtoHexValue(0, 175, 175)); + EntityRegistry.registerModEntity(EntityGiantChickenBase.class, "bigChickenFriendly", mEntityID++, GTplusplus.instance, 64, 20, true); + ItemCustomSpawnEgg.registerEntityForSpawnEgg(2, "bigChickenFriendly", Utils.rgbtoHexValue(255, 0, 0), Utils.rgbtoHexValue(175, 175, 175)); + EntityRegistry.registerModEntity(EntityBatKing.class, "batKing", mEntityID++, GTplusplus.instance, 64, 20, true); + ItemCustomSpawnEgg.registerEntityForSpawnEgg(3, "batKing", Utils.rgbtoHexValue(175, 175, 0), Utils.rgbtoHexValue(0, 175, 175)); //EntityRegistry.registerModEntity(EntityGiantChickenBase.class, "bigChickenFriendly", mEntityID++, GTplusplus.instance, 64, 20, true); @@ -71,9 +73,13 @@ public class InternalEntityRegistry { //Australia EntityRegistry.registerModEntity(EntityAustralianSpiderBase.class, "AusSpider", mEntityID++, GTplusplus.instance, 64, 20, true); + ItemCustomSpawnEgg.registerEntityForSpawnEgg(30, "AusSpider", Utils.rgbtoHexValue(125, 0, 125), Utils.rgbtoHexValue(175, 175, 175)); EntityRegistry.registerModEntity(EntityBoar.class, "AusBoar", mEntityID++, GTplusplus.instance, 64, 20, true); + ItemCustomSpawnEgg.registerEntityForSpawnEgg(31, "AusBoar", Utils.rgbtoHexValue(75, 75, 0), Utils.rgbtoHexValue(175, 175, 75)); EntityRegistry.registerModEntity(EntityDingo.class, "AusDingo", mEntityID++, GTplusplus.instance, 64, 20, true); + ItemCustomSpawnEgg.registerEntityForSpawnEgg(32, "AusDingo", Utils.rgbtoHexValue(175, 125, 0), Utils.rgbtoHexValue(175, 75, 175)); EntityRegistry.registerModEntity(EntityOctopus.class, "AusOctopus", mEntityID++, GTplusplus.instance, 32, 20, true); + ItemCustomSpawnEgg.registerEntityForSpawnEgg(33, "AusOctopus", Utils.rgbtoHexValue(150, 50, 150), Utils.rgbtoHexValue(75, 175, 175)); //EntityRegistry.registerGlobalEntityID(EntityAustralianSpiderBase.class, "AusSpider", EntityRegistry.findGlobalUniqueEntityId(), Utils.rgbtoHexValue(255, 0, 0), Utils.rgbtoHexValue(175, 175, 175)); //EntityRegistry.registerGlobalEntityID(EntityBoar.class, "AusBoar", EntityRegistry.findGlobalUniqueEntityId(), Utils.rgbtoHexValue(255, 0, 0), Utils.rgbtoHexValue(175, 175, 175)); //EntityRegistry.registerGlobalEntityID(EntityDingo.class, "AusDingo", EntityRegistry.findGlobalUniqueEntityId(), Utils.rgbtoHexValue(255, 0, 0), Utils.rgbtoHexValue(175, 175, 175)); diff --git a/src/Java/gtPlusPlus/core/gui/machine/GUI_EggBox.java b/src/Java/gtPlusPlus/core/gui/machine/GUI_EggBox.java new file mode 100644 index 0000000000..49d9890d3a --- /dev/null +++ b/src/Java/gtPlusPlus/core/gui/machine/GUI_EggBox.java @@ -0,0 +1,60 @@ +package gtPlusPlus.core.gui.machine; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.ResourceLocation; + +import gtPlusPlus.core.container.Container_EggBox; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.tileentities.general.TileEntityEggBox; + +@SideOnly(Side.CLIENT) +public class GUI_EggBox extends GuiContainer { + + private static final ResourceLocation craftingTableGuiTextures = new ResourceLocation(CORE.MODID, "textures/gui/FishTrap.png"); + + public GUI_EggBox(final InventoryPlayer player_inventory, final TileEntityEggBox te){ + super(new Container_EggBox(player_inventory, te)); + } + + + @Override + protected void drawGuiContainerForegroundLayer(final int i, final int j){ + //this.fontRendererObj.drawString(I18n.format("Workbench", new Object[0]), 28, 6, 4210752); + this.fontRendererObj.drawString(I18n.format("container.EggBox", new Object[0]), 8, this.ySize - 96 + 2, 4210752); + + } + + + @Override + protected void drawGuiContainerBackgroundLayer(final float f, final int i, final int j){ + GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + this.mc.renderEngine.bindTexture(craftingTableGuiTextures); + final int x = (this.width - this.xSize) / 2; + final int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + } + + + //This method is called when the Gui is first called! + @Override + public void initGui() + { + //You have to add this line for the Gui to function properly! + super.initGui(); + + //The parameters of GuiButton are(id, x, y, width, height, text); + //this.buttonList.add(new GuiButton( 1, 367, 132, 18, 18, "X")); + //this.buttonList.add(new GuiButton( 2, 385, 132, 18, 18, "Y")); + //NOTE: the id always has to be different or else it might get called twice or never! + + //Add any other buttons here too! + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/handler/GuiHandler.java b/src/Java/gtPlusPlus/core/handler/GuiHandler.java index e44c9a8f20..542403bbcb 100644 --- a/src/Java/gtPlusPlus/core/handler/GuiHandler.java +++ b/src/Java/gtPlusPlus/core/handler/GuiHandler.java @@ -5,19 +5,7 @@ import cpw.mods.fml.common.network.NetworkRegistry; import gtPlusPlus.GTplusplus; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.machine.Machine_SuperJukebox.TileEntitySuperJukebox; -import gtPlusPlus.core.container.Container_BackpackBase; -import gtPlusPlus.core.container.Container_CircuitProgrammer; -import gtPlusPlus.core.container.Container_DecayablesChest; -import gtPlusPlus.core.container.Container_FishTrap; -import gtPlusPlus.core.container.Container_Grindle; -import gtPlusPlus.core.container.Container_ModularityTable; -import gtPlusPlus.core.container.Container_PestKiller; -import gtPlusPlus.core.container.Container_ProjectTable; -import gtPlusPlus.core.container.Container_RoundRobinator; -import gtPlusPlus.core.container.Container_SuperJukebox; -import gtPlusPlus.core.container.Container_TradeTable; -import gtPlusPlus.core.container.Container_Workbench; -import gtPlusPlus.core.container.Container_WorkbenchAdvanced; +import gtPlusPlus.core.container.*; import gtPlusPlus.core.container.box.LunchBoxContainer; import gtPlusPlus.core.container.box.MagicBagContainer; import gtPlusPlus.core.container.box.ToolBoxContainer; @@ -28,17 +16,7 @@ import gtPlusPlus.core.gui.item.GuiBaseGrindle; import gtPlusPlus.core.gui.item.box.LunchBoxGui; import gtPlusPlus.core.gui.item.box.MagicBagGui; import gtPlusPlus.core.gui.item.box.ToolBoxGui; -import gtPlusPlus.core.gui.machine.GUI_CircuitProgrammer; -import gtPlusPlus.core.gui.machine.GUI_DecayablesChest; -import gtPlusPlus.core.gui.machine.GUI_FishTrap; -import gtPlusPlus.core.gui.machine.GUI_ModularityTable; -import gtPlusPlus.core.gui.machine.GUI_PestKiller; -import gtPlusPlus.core.gui.machine.GUI_ProjectTable; -import gtPlusPlus.core.gui.machine.GUI_RoundRobinator; -import gtPlusPlus.core.gui.machine.GUI_SuperJukebox; -import gtPlusPlus.core.gui.machine.GUI_TradeTable; -import gtPlusPlus.core.gui.machine.GUI_Workbench; -import gtPlusPlus.core.gui.machine.GUI_WorkbenchAdvanced; +import gtPlusPlus.core.gui.machine.*; import gtPlusPlus.core.interfaces.IGuiManager; import gtPlusPlus.core.inventories.BaseInventoryBackpack; import gtPlusPlus.core.inventories.BaseInventoryGrindle; @@ -46,9 +24,7 @@ import gtPlusPlus.core.inventories.box.LunchBoxInventory; import gtPlusPlus.core.inventories.box.MagicBagInventory; import gtPlusPlus.core.inventories.box.ToolBoxInventory; import gtPlusPlus.core.tileentities.base.TileEntityBase; -import gtPlusPlus.core.tileentities.general.TileEntityCircuitProgrammer; -import gtPlusPlus.core.tileentities.general.TileEntityDecayablesChest; -import gtPlusPlus.core.tileentities.general.TileEntityFishTrap; +import gtPlusPlus.core.tileentities.general.*; import gtPlusPlus.core.tileentities.machines.TileEntityModularityTable; import gtPlusPlus.core.tileentities.machines.TileEntityPestKiller; import gtPlusPlus.core.tileentities.machines.TileEntityProjectTable; @@ -79,6 +55,7 @@ public class GuiHandler implements IGuiHandler { public static final int GUI14 = 13; // Super Jukebox public static final int GUI15 = 14; // Pest Killer public static final int GUI16 = 15; // Round-Robinator + public static final int GUI17 = 16; // Egg Box public static void init() { @@ -129,6 +106,8 @@ public class GuiHandler implements IGuiHandler { return new Container_PestKiller(player.inventory, (TileEntityPestKiller) te); } else if (ID == GUI16) { return new Container_RoundRobinator(player.inventory, (TileEntityRoundRobinator) te); + } else if (ID == GUI17) { + return new Container_EggBox(player.inventory, (TileEntityEggBox) te); } } @@ -191,6 +170,8 @@ public class GuiHandler implements IGuiHandler { return new GUI_PestKiller(player.inventory, (TileEntityPestKiller) te); } else if (ID == GUI16) { return new GUI_RoundRobinator(player.inventory, (TileEntityRoundRobinator) te); + } else if (ID == GUI17) { + return new GUI_EggBox(player.inventory, (TileEntityEggBox) te); } } diff --git a/src/Java/gtPlusPlus/core/inventories/Inventory_EggBox.java b/src/Java/gtPlusPlus/core/inventories/Inventory_EggBox.java new file mode 100644 index 0000000000..334afc3300 --- /dev/null +++ b/src/Java/gtPlusPlus/core/inventories/Inventory_EggBox.java @@ -0,0 +1,176 @@ +package gtPlusPlus.core.inventories; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; + +public class Inventory_EggBox implements IInventory{ + + private final String name = "EggBox"; + + /** Defining your inventory size this way is handy */ + public static final int INV_SIZE = 15; + + /** Inventory's size must be same as number of slots you add to the Container class */ + private ItemStack[] inventory = new ItemStack[INV_SIZE]; + + public void readFromNBT(final NBTTagCompound nbt){ + final NBTTagList list = nbt.getTagList("Items", 10); + this.inventory = new ItemStack[INV_SIZE]; + for(int i = 0;i<list.tagCount();i++){ + final NBTTagCompound data = list.getCompoundTagAt(i); + final int slot = data.getInteger("Slot"); + if((slot >= 0) && (slot < INV_SIZE)){ + //Utils.LOG_INFO("Trying to read NBT data from inventory."); + this.inventory[slot] = ItemStack.loadItemStackFromNBT(data); + } + } + } + + public void writeToNBT(final NBTTagCompound nbt){ + final NBTTagList list = new NBTTagList(); + for(int i = 0;i<INV_SIZE;i++){ + final ItemStack stack = this.inventory[i]; + if(stack != null){ + //Utils.LOG_INFO("Trying to write NBT data to inventory."); + final NBTTagCompound data = new NBTTagCompound(); + stack.writeToNBT(data); + data.setInteger("Slot", i); + list.appendTag(data); + } + } + nbt.setTag("Items", list); + } + + @Override + public int getSizeInventory() + { + return this.inventory.length; + } + + public ItemStack[] getInventory(){ + return this.inventory; + } + + @Override + public ItemStack getStackInSlot(final int slot) + { + return this.inventory[slot]; + } + + @Override + public ItemStack decrStackSize(final int slot, final int amount) + { + ItemStack stack = this.getStackInSlot(slot); + if(stack != null) + { + if(stack.stackSize > amount) + { + stack = stack.splitStack(amount); + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } + else + { + // this method also calls markDirty, so we don't need to call it again + this.setInventorySlotContents(slot, null); + } + } + return stack; + } + + @Override + public ItemStack getStackInSlotOnClosing(final int slot) + { + final ItemStack stack = this.getStackInSlot(slot); + this.setInventorySlotContents(slot, null); + return stack; + } + + @Override + public void setInventorySlotContents(final int slot, final ItemStack stack) + { + this.inventory[slot] = stack; + + if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) + { + stack.stackSize = this.getInventoryStackLimit(); + } + + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } + + // 1.7.2+ renamed to getInventoryName + @Override + public String getInventoryName() + { + return this.name; + } + + // 1.7.2+ renamed to hasCustomInventoryName + @Override + public boolean hasCustomInventoryName() + { + return this.name.length() > 0; + } + + @Override + public int getInventoryStackLimit() + { + return 64; + } + + /** + * This is the method that will handle saving the inventory contents, as it is called (or should be called!) + * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also + * let you change things in your inventory without ever opening a Gui, if you want. + */ + // 1.7.2+ renamed to markDirty + @Override + public void markDirty() + { + for (int i = 0; i < this.getSizeInventory(); ++i) + { + final ItemStack temp = this.getStackInSlot(i); + if (temp != null){ + //Utils.LOG_INFO("Slot "+i+" contains "+temp.getDisplayName()+" x"+temp.stackSize); + } + + if ((temp != null) && (temp.stackSize == 0)) { + this.inventory[i] = null; + } + } + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer entityplayer) + { + return true; + } + + // 1.7.2+ renamed to openInventory(EntityPlayer player) + @Override + public void openInventory() {} + + // 1.7.2+ renamed to closeInventory(EntityPlayer player) + @Override + public void closeInventory() {} + + /** + * This method doesn't seem to do what it claims to do, as + * items can still be left-clicked and placed in the inventory + * even when this returns false + */ + @Override + public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) + { + // Don't want to be able to store the inventory item within itself + // Bad things will happen, like losing your inventory + // Actually, this needs a custom Slot to work + return true; + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/item/ModItems.java b/src/Java/gtPlusPlus/core/item/ModItems.java index fd2b98c7be..1726a22a7b 100644 --- a/src/Java/gtPlusPlus/core/item/ModItems.java +++ b/src/Java/gtPlusPlus/core/item/ModItems.java @@ -60,6 +60,7 @@ import gtPlusPlus.core.item.general.capture.ItemEntityCatcher; import gtPlusPlus.core.item.general.chassis.ItemBoilerChassis; import gtPlusPlus.core.item.general.chassis.ItemDehydratorCoil; import gtPlusPlus.core.item.general.chassis.ItemDehydratorCoilWire; +import gtPlusPlus.core.item.general.spawn.ItemCustomSpawnEgg; import gtPlusPlus.core.item.general.throwables.ItemHydrofluoricAcidPotion; import gtPlusPlus.core.item.general.throwables.ItemSulfuricAcidPotion; import gtPlusPlus.core.item.general.throwables.ItemThrowableBomb; @@ -111,7 +112,6 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; public final class ModItems { - public static ToolMaterial STABALLOY = EnumHelper.addToolMaterial("Staballoy", 3, 2500, 7, 1.0F, 18); public static Item ZZZ_Empty; @@ -120,7 +120,7 @@ public final class ModItems { public static Item itemAlkalusDisk; public static Item itemDebugShapeSpawner; - public static Item itemBaseSpawnEgg; + public static ItemCustomSpawnEgg itemCustomSpawnEgg; //EnderIO public static Item itemPlateSoularium; @@ -317,7 +317,7 @@ public final class ModItems { public static Item dustDecayedRadium226; public static Item dustRadium226; - public static Item itemBigEgg; + public static ItemGiantEgg itemBigEgg; public static GregtechPump toolGregtechPump; @@ -384,9 +384,10 @@ public final class ModItems { itemDebugScanner = new DebugScanner(); itemAlkalusDisk = new BaseItemDamageable("itemAlkalusDisk", AddToCreativeTab.tabMisc, 1, 0, "Unknown Use", EnumRarity.rare, EnumChatFormatting.AQUA, false, null); - itemBigEgg = new ItemGiantEgg("itemBigEgg", "Ginourmous Chicken Egg", tabMisc, 64, 0, "I had best try disassemble this.. for science!", "fuelLargeChickenEgg", 5000, 0).setTextureName(CORE.MODID + ":itemBigEgg"); + itemBigEgg = new ItemGiantEgg(); itemGenericToken = new ItemGenericToken(); itemDummyResearch = new ItemDummyResearch(); + itemCustomSpawnEgg = new ItemCustomSpawnEgg(); //Debug Loading if (CORE_Preloader.DEBUG_MODE){ diff --git a/src/Java/gtPlusPlus/core/item/base/BaseItemTickable.java b/src/Java/gtPlusPlus/core/item/base/BaseItemTickable.java index 54710662d8..79a49f92b7 100644 --- a/src/Java/gtPlusPlus/core/item/base/BaseItemTickable.java +++ b/src/Java/gtPlusPlus/core/item/base/BaseItemTickable.java @@ -14,10 +14,11 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IIcon; import net.minecraft.world.World; - +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; public class BaseItemTickable extends CoreItem { @@ -57,7 +58,7 @@ public class BaseItemTickable extends CoreItem { } - boolean active = getIsActive(world, iStack); + boolean active = isTicking(world, iStack); if (active) { tickItemTag(world, iStack); } @@ -113,12 +114,15 @@ public class BaseItemTickable extends CoreItem { } } + protected int getMaxTicks(ItemStack aStack) { + return maxTicks; + } - private boolean createNBT(World world, ItemStack rStack){ + protected boolean createNBT(World world, ItemStack rStack){ final NBTTagCompound tagMain = new NBTTagCompound(); final NBTTagCompound tagNBT = new NBTTagCompound(); tagNBT.setLong("Tick", 0); - tagNBT.setLong("maxTick", this.maxTicks); + tagNBT.setLong("maxTick", getMaxTicks(rStack)); tagNBT.setBoolean("isActive", true); //Try set world time @@ -127,11 +131,12 @@ public class BaseItemTickable extends CoreItem { } tagMain.setTag("TickableItem", tagNBT); - rStack.setTagCompound(tagMain); + rStack.setTagCompound(tagMain); + Logger.INFO("Created Tickable NBT data."); return true; } - public final long getFilterDamage(World world, final ItemStack aStack) { + public final long getTicks(World world, final ItemStack aStack) { NBTTagCompound aNBT = aStack.getTagCompound(); if (aNBT != null) { aNBT = aNBT.getCompoundTag("TickableItem"); @@ -145,7 +150,7 @@ public class BaseItemTickable extends CoreItem { return 0L; } - public final boolean setFilterDamage(World world, final ItemStack aStack, final long aDamage) { + public final boolean setTicks(World world, final ItemStack aStack, final long aDamage) { NBTTagCompound aNBT = aStack.getTagCompound(); if (aNBT != null) { aNBT = aNBT.getCompoundTag("TickableItem"); @@ -160,7 +165,7 @@ public class BaseItemTickable extends CoreItem { return false; } - public final boolean getIsActive(World world, final ItemStack aStack) { + public final boolean isTicking(World world, final ItemStack aStack) { NBTTagCompound aNBT = aStack.getTagCompound(); if (aNBT != null) { aNBT = aNBT.getCompoundTag("TickableItem"); @@ -174,7 +179,7 @@ public class BaseItemTickable extends CoreItem { return true; } - public final boolean setIsActive(World world, final ItemStack aStack, final boolean active) { + public final boolean setTicking(World world, final ItemStack aStack, final boolean active) { NBTTagCompound aNBT = aStack.getTagCompound(); if (aNBT != null) { aNBT = aNBT.getCompoundTag("TickableItem"); @@ -251,26 +256,15 @@ public class BaseItemTickable extends CoreItem { NBTTagCompound aNBT = aStack.getTagCompound(); if (aNBT != null) { if (aNBT.hasKey("TickableItem")) { - aNBT = aNBT.getCompoundTag("TickableItem"); - - /*if (!aNBT.hasKey("CreationDate") && world != null) { - aNBT.setLong("CreationDate", world.getTotalWorldTime()); - }*/ - + aNBT = aNBT.getCompoundTag("TickableItem"); //Done Ticking - if (maxTicks-getFilterDamage(world, aStack) <= 0) { - setIsActive(world, aStack, false); + if (getMaxTicks(aStack)-getTicks(world, aStack) <= 0) { + setTicking(world, aStack, false); return false; } - if (getIsActive(world, aStack)) { + if (isTicking(world, aStack)) { if (aNBT != null) { - - //if ((world.getTotalWorldTime()-)) - - // Just tick once - aNBT.setLong("Tick", getFilterDamage(world, aStack)+1); - - + aNBT.setLong("Tick", getTicks(world, aStack)+1); return true; } else { @@ -288,10 +282,11 @@ public class BaseItemTickable extends CoreItem { @Override public double getDurabilityForDisplay(ItemStack stack) { if (stack.getTagCompound() == null){ - createNBT(null, stack); + //createNBT(null, stack); + return 0; } - double currentDamage = getFilterDamage(null, stack); - double durabilitypercent = currentDamage / maxTicks; + double currentDamage = getTicks(null, stack); + double durabilitypercent = currentDamage / getMaxTicks(stack); return durabilitypercent; } @@ -302,23 +297,28 @@ public class BaseItemTickable extends CoreItem { if (this.descriptionString.length > 0) { list.add(EnumChatFormatting.GRAY+this.descriptionString[0]); } + long maxTicks = getMaxTicks(stack); + long ticks = 0; + if (stack.hasTagCompound()) { + ticks = getTicks(world, stack); + } EnumChatFormatting durability = EnumChatFormatting.GRAY; - if (maxTicks-getFilterDamage(world, stack) > (maxTicks*0.8)){ + if (maxTicks-ticks > (maxTicks*0.8)){ durability = EnumChatFormatting.GRAY; } - else if (maxTicks-getFilterDamage(world, stack) > (maxTicks*0.6)){ + else if (maxTicks-ticks > (maxTicks*0.6)){ durability = EnumChatFormatting.GREEN; } - else if (maxTicks-getFilterDamage(world, stack) > (maxTicks*0.4)){ + else if (maxTicks-ticks > (maxTicks*0.4)){ durability = EnumChatFormatting.YELLOW; } - else if (maxTicks-getFilterDamage(world, stack) > (maxTicks*0.2)){ + else if (maxTicks-ticks > (maxTicks*0.2)){ durability = EnumChatFormatting.GOLD; } - else if (maxTicks-getFilterDamage(world, stack) > 0){ + else if (maxTicks-ticks > 0){ durability = EnumChatFormatting.RED; } - list.add(durability+""+((maxTicks-getFilterDamage(world, stack))/20)+EnumChatFormatting.GRAY+" seconds until decay"); + list.add(durability+""+((maxTicks-ticks)/20)+EnumChatFormatting.GRAY+" seconds until decay"); if (this.descriptionString.length > 1) { for (int h=1;h<this.descriptionString.length;h++) { diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBasicTile.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBasicTile.java index 251230932c..15782c20aa 100644 --- a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBasicTile.java +++ b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBasicTile.java @@ -51,7 +51,10 @@ public class ItemBlockBasicTile extends ItemBlock { list.add("Use either Formaldehyde or Hydrogen cyanide"); list.add("Be weary of your neighbours"); } - else if (this.mID == 7) { + else if (this.mID == 7) { // Egg Box + list.add("A box for holding big eggs"); + list.add("Items which decay will tick while inside"); + list.add("Place with right click"); } else if (this.mID == 8){ diff --git a/src/Java/gtPlusPlus/core/item/general/ItemGiantEgg.java b/src/Java/gtPlusPlus/core/item/general/ItemGiantEgg.java index d98b27d163..b3338bb681 100644 --- a/src/Java/gtPlusPlus/core/item/general/ItemGiantEgg.java +++ b/src/Java/gtPlusPlus/core/item/general/ItemGiantEgg.java @@ -4,188 +4,232 @@ import static gtPlusPlus.core.lib.CORE.RANDOM; import java.util.List; -import gregtech.api.enums.ItemList; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.entity.item.ItemEntityGiantEgg; -import gtPlusPlus.core.item.base.BaseItemBurnable; +import gtPlusPlus.core.item.base.BaseItemTickable; +import gtPlusPlus.core.item.general.spawn.ItemCustomSpawnEgg; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.NBTUtils; -import net.minecraft.creativetab.CreativeTabs; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityList; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.MathHelper; -import net.minecraft.util.StatCollector; import net.minecraft.world.World; -public class ItemGiantEgg extends BaseItemBurnable { +public class ItemGiantEgg extends BaseItemTickable { - public ItemGiantEgg(String unlocalizedName, String displayName, CreativeTabs creativeTab, int stackSize, int maxDmg, - String description, String oredictName, int burnTime, int meta) { - super(unlocalizedName, displayName, creativeTab, stackSize, maxDmg, description, oredictName, burnTime, meta); - this.setMaxStackSize(1); - } + private static ItemStack turnsIntoItem; + private static ItemStack mCorrectEgg; + private static ItemStack mCorrectStemCells; - @Override - public String getItemStackDisplayName(ItemStack aStack) { - String localName = super.getItemStackDisplayName(aStack); - nbtWork(aStack); - int size = 1; - if (NBTUtils.hasKey(aStack, "size")){ - size = NBTUtils.getInteger(aStack, "size"); - return ""+size+" "+localName; - } - return "?? "+localName; + public void registerFuel(int burn){ + CORE.burnables.add(new Pair<Integer, ItemStack>(burn, ItemUtils.getSimpleStack(this, 1))); } - private static ItemStack mCorrectEgg; - private static ItemStack mCorrectStemCells; + public final void registerOrdictionary(String name){ + ItemUtils.addItemToOreDictionary(ItemUtils.getSimpleStack(this), name); + } - @Override - public void onUpdate(ItemStack aStack, World world, Entity entityHolding, int p_77663_4_, boolean p_77663_5_) { + public ItemGiantEgg() { + this(Utils.rgbtoHexValue(255, 255, 255), Short.MAX_VALUE * Byte.MAX_VALUE, new String[] {"I had best try disassemble this.. for science!"}); + } - if (world.isRemote) { - super.onUpdate(aStack, world, entityHolding, p_77663_4_, p_77663_5_); - return; - } - try { - boolean player = (entityHolding != null && entityHolding instanceof EntityPlayer); + private ItemGiantEgg(int colour, int maxTicks, String[] desc1) { + super(true, false, "itemBigEgg", colour, maxTicks, desc1); + setTextureName(CORE.MODID + ":itemBigEgg"); + this.setMaxStackSize(1); + registerFuel(5000); + registerOrdictionary("fuelLargeChickenEgg"); + } + + public static void postInit(ItemGiantEgg aGiantEggItem) { + ItemGiantEgg.turnsIntoItem = getSpawnEggStack(); + //new DecayableRecipe(aGiantEggItem.maxTicks, getSimpleStack(aGiantEggItem), ItemUtils.getSimpleStack(ItemGiantEgg.turnsIntoItem, 1)); + } - if (player) { - NBTUtils.setBoolean(aStack, "playerHeld", true); - } - else { - NBTUtils.setBoolean(aStack, "playerHeld", false); - } - - nbtWork(aStack); - - int age = NBTUtils.hasKey(aStack, "mAge") ? NBTUtils.getInteger(aStack, "mAge") : 0; - if (player) { - NBTUtils.setInteger(aStack, "mAge", age+1); - - //Set the correct egg for future hatches - if (mCorrectEgg == null) { - if (NBTUtils.hasKey(aStack, "mAge") && NBTUtils.hasKey(aStack, "mEggAge")) { - if (NBTUtils.getInteger(aStack, "mAge") >= NBTUtils.getInteger(aStack, "mEggAge")) { - for (int g=0;g<128;g++) { - ItemStack mSpawn = ItemUtils.simpleMetaStack(Items.spawn_egg, g, 1); - if (mSpawn != null) { - String s = ("" + StatCollector.translateToLocal(mSpawn.getUnlocalizedName() + ".name")).trim(); - String s1 = EntityList.getStringFromID(mSpawn.getItemDamage()); - if (s1 != null){ - s = s + " " + StatCollector.translateToLocal("entity." + s1 + ".name"); - if (s1.equalsIgnoreCase("bigChickenFriendly")) { - mCorrectEgg = mSpawn; - break; - } - } - } - } + private static ItemStack getSpawnEggStack() { + //Set the correct egg for future hatches + if (mCorrectEgg == null) { + /*for (int g=0;g<Byte.MAX_VALUE;g++) { + ItemStack mSpawn = ItemUtils.simpleMetaStack(Items.spawn_egg, g, 1); + if (mSpawn != null) { + //String s = ("" + StatCollector.translateToLocal(mSpawn.getUnlocalizedName() + ".name")).trim(); + String s1 = EntityList.getStringFromID(mSpawn.getItemDamage()); + if (s1 != null){ + //s = s + " " + StatCollector.translateToLocal("entity." + s1 + ".name"); + if (s1.equalsIgnoreCase("bigChickenFriendly")) { + mCorrectEgg = mSpawn; + return mCorrectEgg; } } - } + } + }*/ + ItemStack aTempEgg = ItemCustomSpawnEgg.getSpawnEggForEntityname("bigChickenFriendly", 1); + if (aTempEgg != null) { + mCorrectEgg = aTempEgg; + } + } + return mCorrectEgg; + } - if (mCorrectEgg != null) { - if (NBTUtils.hasKey(aStack, "mAge") && NBTUtils.hasKey(aStack, "mEggAge")) { - if (NBTUtils.getInteger(aStack, "mAge") >= NBTUtils.getInteger(aStack, "mEggAge")) { - if (MathUtils.randInt(0, 1000) >= 990) { - if (NBTUtils.hasKey(aStack, "size")) { - if ((NBTUtils.getInteger(aStack, "size")+1) >= MathUtils.randInt(0, 9)) { - ((EntityPlayer) entityHolding).inventory.addItemStackToInventory((mCorrectEgg)); - ((EntityPlayer) entityHolding).inventory.consumeInventoryItem(this); - } - else { - ((EntityPlayer) entityHolding).inventory.consumeInventoryItem(this); - } - } - } - } - } + private static ItemStack getStemCellStack() { + if (mCorrectStemCells == null) { + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && Utils.getGregtechSubVersion() > 28) { + ItemStack xl = ItemUtils.getValueOfItemList("Circuit_Chip_Stemcell", 1, ItemUtils.getSimpleStack(Items.egg, 2)); + if (xl != null) { + mCorrectStemCells = xl.copy(); } } + else { + mCorrectStemCells = ItemUtils.getSimpleStack(Items.egg, 2); + } } - catch (Throwable t) { - t.printStackTrace(); - } + return mCorrectStemCells; + } - super.onUpdate(aStack, world, entityHolding, p_77663_4_, p_77663_5_); + protected int getMaxTicks(ItemStack aStack) { + if (aStack != null && aStack.hasTagCompound() && aStack.getTagCompound().hasKey("mEggAge")) { + return NBTUtils.getInteger(aStack, "mEggAge"); + } + return maxTicks; } @Override - public void onCreated(ItemStack p_77622_1_, World p_77622_2_, EntityPlayer p_77622_3_) { - super.onCreated(p_77622_1_, p_77622_2_, p_77622_3_); + public void registerIcons(final IIconRegister i) { + this.mIcon[0] = i.registerIcon(CORE.MODID + ":" + "itemBigEgg"); } - public void nbtWork(ItemStack aStack) { - if (NBTUtils.hasKey(aStack, "playerHeld")) { - boolean player = NBTUtils.getBoolean(aStack, "playerHeld"); - if (player && !NBTUtils.hasKey(aStack, "size")) { - NBTUtils.setInteger(aStack, "size", MathUtils.randInt(1, 8)); + + @Override + protected boolean createNBT(World world, ItemStack aStack){ + + if (aStack.getTagCompound() != null && aStack.getTagCompound().hasKey("size")) { + return false; + } + Logger.INFO("Egg: "+ReflectionUtils.getMethodName(1)); + Logger.INFO("Egg: "+ReflectionUtils.getMethodName(2)); + Logger.INFO("Egg: "+ReflectionUtils.getMethodName(3)); + Logger.INFO("Egg: "+ReflectionUtils.getMethodName(4)); + Logger.INFO("Egg: "+ReflectionUtils.getMethodName(5)); + Logger.INFO("Egg: "+ReflectionUtils.getMethodName(6)); + //Logger.INFO("Creating Egg NBT."); + boolean aSuper = super.createNBT(world, aStack); + int size = MathUtils.randInt(1, 8); + NBTUtils.setInteger(aStack, "size", size); + NBTUtils.setInteger(aStack, "mEggAge", ((MathUtils.randInt(8000, 16000)*size))); + ItemStack aStemCells = getStemCellStack(); + if (aStemCells != null) { + int mSize = NBTUtils.getInteger(aStack, "size"); + float mSizeMod = (MathUtils.randInt(-5, 5)/5); + mSize += mSizeMod; + mSize = Math.max(mSize, 1); + ItemStack eggYolks[] = new ItemStack[mSize]; + for (int u=0;u<mSize;u++) { + eggYolks[u] = ItemUtils.getSimpleStack(aStemCells, MathUtils.randInt(1, 4)); } - if (player && !NBTUtils.hasKey(aStack, "mEggAge") && NBTUtils.hasKey(aStack, "size")) { - NBTUtils.setInteger(aStack, "mEggAge", ((MathUtils.randInt(8000, 16000)*NBTUtils.getInteger(aStack, "size"))/2)); + int mexpected = 0; + for (ItemStack e : eggYolks) { + if (e != null) { + mexpected += e.stackSize; + } } + if (mexpected > 0) { + NBTUtils.setInteger(aStack, "mExpected", mexpected); + NBTUtils.writeItemsToGtCraftingComponents(aStack, new ItemStack[]{ ItemUtils.getSimpleStack(aStemCells, mexpected)}, true); + } + } + return aSuper; + + } - if (player && NBTUtils.getTagCompound(aStack, "GT.CraftingComponents") == null) { - if (mCorrectStemCells == null) { - if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && Utils.getGregtechSubVersion() > 28) { - - ItemList xl = ItemUtils.getValueOfItemList("Circuit_Chip_Stemcell", ItemList.Circuit_Elite); - if (xl != null && xl.hasBeenSet()) { - mCorrectStemCells = xl.get(1); - } - } - else { - mCorrectStemCells = ItemUtils.getSimpleStack(Items.egg, 2); - } - } - if (mCorrectStemCells != null) { - int mSize = NBTUtils.getInteger(aStack, "size"); - float mSizeMod = (MathUtils.randInt(-5, 5)/10); - mSize += mSizeMod; - mSize = Math.max(mSize, 1); - ItemStack eggYolks[] = new ItemStack[mSize]; - for (int u=0;u<mSize;u++) { - eggYolks[u] = ItemUtils.getSimpleStack(mCorrectStemCells, MathUtils.randInt(1, 4)); - } + @Override + public void onUpdate(final ItemStack iStack, final World world, final Entity entityHolding, final int p_77663_4_, final boolean p_77663_5_) { + if (world == null || iStack == null) { + return; + } + if (world.isRemote) { + return; + } + if (iStack.getTagCompound() == null || !iStack.getTagCompound().hasKey("size")) { + this.createNBT(world, iStack); + Logger.INFO("Egg has no NBT, creating (onUpdate)"); + } + boolean a1, a2; + a1 = this.isTicking(world, iStack); + a2 = a1 ? tickItemTag(world, iStack) : false; - int mexpected = 0; - for (ItemStack e : eggYolks) { - if (e != null) { - mexpected += e.stackSize; + //Logger.INFO("Is Ticking? "+a1); + //Logger.INFO("Did Tick? "+a2); + if (!a1 && !a2) { + if (entityHolding instanceof EntityPlayer){ + if (MathUtils.randInt(0, 1000) >= 990) { + if (NBTUtils.hasKey(iStack, "size")) { + if ((NBTUtils.getInteger(iStack, "size")+1) >= MathUtils.randInt(0, 9)) { + ItemStack replacement = ItemUtils.getSimpleStack(getHatchResult(), 1); + if (replacement == null) { + + } + //Logger.INFO("Replacing "+iStack.getDisplayName()+" with "+replacement.getDisplayName()+"."); + final ItemStack tempTransform = replacement.copy(); + if (iStack.stackSize > 1){ + int u = iStack.stackSize; + tempTransform.stackSize = u; + ((EntityPlayer) entityHolding).inventory.addItemStackToInventory((tempTransform)); + for (int l=0;l<u;l++){ + ((EntityPlayer) entityHolding).inventory.consumeInventoryItem(this); + } + } + else { + tempTransform.stackSize=1; + ((EntityPlayer) entityHolding).inventory.addItemStackToInventory((tempTransform)); + ((EntityPlayer) entityHolding).inventory.consumeInventoryItem(this); + } } } - if (mexpected > 0) { - NBTUtils.setInteger(aStack, "mExpected", mexpected); - } - - NBTUtils.writeItemsToGtCraftingComponents(aStack, eggYolks, true); } } - if (player && NBTUtils.getTagCompound(aStack, "GT.CraftingComponents") != null) { + } + } - } - } + public ItemStack getHatchResult() { + return turnsIntoItem; } @Override + public String getItemStackDisplayName(ItemStack aStack) { + String localName = super.getItemStackDisplayName(aStack); + /*if (aStack.getTagCompound() == null){ + createNBT(null, aStack); + Logger.INFO("Egg has no NBT, creating (getDisplayName)"); + }*/ + int size = 1; + if (NBTUtils.hasKey(aStack, "size")){ + size = NBTUtils.getInteger(aStack, "size"); + return ""+size+" "+localName; + } + return "?? "+localName; + } + + + @Override public boolean hasCustomEntity(ItemStack stack) { return true; } @Override public Entity createEntity(World world, Entity location, ItemStack itemstack) { - if (location instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) location; - if (itemstack == null) { return null; } @@ -217,27 +261,40 @@ public class ItemGiantEgg extends BaseItemBurnable { @Override public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { int size = 0; - if (NBTUtils.hasKey(stack, "size")){ - size = NBTUtils.getInteger(stack, "size"); - } - int age = 0; - if (NBTUtils.hasKey(stack, "mAge")){ - age = NBTUtils.getInteger(stack, "mAge"); - } - int life = 0; - if (NBTUtils.hasKey(stack, "mEggAge")){ - life = NBTUtils.getInteger(stack, "mEggAge"); - } + long age = 0; + long life = 0; int expected = 0; - if (NBTUtils.hasKey(stack, "mExpected")){ - expected = NBTUtils.getInteger(stack, "mExpected"); + if (this.descriptionString.length > 0) { + list.add(EnumChatFormatting.GRAY+this.descriptionString[0]); } - list.add("Egg Size: "+size+" ounces"); - list.add("Expected Stem Cells: "+expected); - list.add("Age: "+(age/20)+"s"+" / "+(life/20)+"s"); + if (NBTUtils.hasKey(stack, "size")){ + size = NBTUtils.getInteger(stack, "size"); + if (size > 0 && NBTUtils.hasKey(stack, "TickableItem")){ + NBTTagCompound aNBT = stack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("TickableItem"); + if (aNBT != null) { + age = aNBT.getLong("Tick"); + } + } + } + if (NBTUtils.hasKey(stack, "mEggAge")){ + life = NBTUtils.getInteger(stack, "mEggAge"); + } + if (NBTUtils.hasKey(stack, "mExpected")){ + expected = NBTUtils.getInteger(stack, "mExpected"); + } + } + String aSize = size > 0 ? ""+size : "??"; + String aExpected = expected > 0 ? ""+expected : "??"; + String aAge = age > 0 ? ""+(age/20) : "??"; + String aLife = life > 0 ? ""+(life/20) : "??"; + list.add("Egg Size: "+aSize+" ounces"); + list.add("Expected Stem Cells: "+aExpected); + list.add("Age: "+aAge+"s"+" / "+aLife+"s"); list.add("Larger eggs take longer to hatch,"); - list.add("but have a better chance of hatching."); - super.addInformation(stack, aPlayer, list, bool); + list.add("but have a better chance of hatching."); + } } diff --git a/src/Java/gtPlusPlus/core/item/general/spawn/ItemCustomSpawnEgg.java b/src/Java/gtPlusPlus/core/item/general/spawn/ItemCustomSpawnEgg.java new file mode 100644 index 0000000000..727b933fa7 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/general/spawn/ItemCustomSpawnEgg.java @@ -0,0 +1,285 @@ +package gtPlusPlus.core.item.general.spawn; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.ItemUtils; +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.*; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.*; +import net.minecraft.util.*; +import net.minecraft.world.World; + +public class ItemCustomSpawnEgg extends ItemMonsterPlacer { + + private static final HashMap<Integer, IIcon> mIconMap = new HashMap<Integer, IIcon>(); + private static int mTotalMetaItems = 0; + + private static final HashMap<Integer, Integer> mMaxStackSizeMap = new HashMap<Integer, Integer>(); + private static final HashMap<Integer, EnumRarity> mRarityMap = new HashMap<Integer, EnumRarity>(); + private static final HashMap<Integer, ArrayList<String>> mOreDictNames = new HashMap<Integer, ArrayList<String>>(); + + private static final HashMap<Integer, Integer> mColourBaseMap = new HashMap<Integer, Integer>(); + private static final HashMap<Integer, Integer> mColourSpotsMap = new HashMap<Integer, Integer>(); + private static final HashMap<Integer, String> mEntityNameMap = new HashMap<Integer, String>(); + private static final HashMap<Integer, String> mEntityFullNameMap = new HashMap<Integer, String>(); + + private static final HashMap<String, Integer> mReverseEntityMap = new HashMap<String, Integer>(); + + protected EntityLiving entityToSpawn = null; + + public static ItemStack getSpawnEggForEntityname(String aEntityName, int aSize) { + return ItemUtils.simpleMetaStack(ModItems.itemCustomSpawnEgg, mReverseEntityMap.get(aEntityName), aSize); + } + + public static void registerEntityForSpawnEgg(final int aMetaID, String parEntityToSpawnName, int aPrimaryColor, int aSecondaryColor) { + registerEntityForSpawnEgg(aMetaID, parEntityToSpawnName, aPrimaryColor, aSecondaryColor, EnumRarity.common, new ArrayList<String>()); + } + + public static void registerEntityForSpawnEgg(final int aMetaID, String parEntityToSpawnName, int aPrimaryColor, int aSecondaryColor, EnumRarity aRarity, final ArrayList<String> aOreDictNames) { + mTotalMetaItems++; + mMaxStackSizeMap.put(aMetaID, 64); + mRarityMap.put(aMetaID, aRarity); + mOreDictNames.put(aMetaID, aOreDictNames); + mColourBaseMap.put(aMetaID, aPrimaryColor); + mColourSpotsMap.put(aMetaID, aSecondaryColor); + mReverseEntityMap.put(parEntityToSpawnName, aMetaID); + setEntityToSpawnName(aMetaID, parEntityToSpawnName); + } + + public static void registerEggsToOreDict() { + for (int aMetaID = 0; aMetaID < mTotalMetaItems; aMetaID++) { + ArrayList<String> aOreDictNames = mOreDictNames.get(aMetaID); + if (aOreDictNames != null && !aOreDictNames.isEmpty()) { + ItemStack aFoodStack = ItemUtils.simpleMetaStack(ModItems.itemCustomSpawnEgg, aMetaID, 1 + ); + for (String aOreName : aOreDictNames) { + ItemUtils.addItemToOreDictionary(aFoodStack, aOreName); + } + } + } + } + + public ItemCustomSpawnEgg() { + super(); + this.setNoRepair(); + this.setMaxStackSize(64); + this.setMaxDamage(0); + this.setUnlocalizedName("BasicMetaSpawnEgg"); + GameRegistry.registerItem(this, this.getUnlocalizedName()); + } + + /** + * 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; + } + else { + 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(par1ItemStack, 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; + } + else { + MovingObjectPosition movingobjectposition = getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, true); + + if (movingobjectposition == null) { + return par1ItemStack; + } + else { + 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(par1ItemStack, 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. + * @param par1ItemStack + */ + public Entity spawnEntity(ItemStack par1ItemStack, World parWorld, double parX, double parY, double parZ) { + + if (!parWorld.isRemote) // never spawn entity on client side + { + int aDamage = par1ItemStack.getItemDamage(); + String entityToSpawnNameFull = mEntityFullNameMap.get(aDamage); + String entityToSpawnName = mEntityNameMap.get(aDamage); + //entityToSpawnNameFull = WildAnimals.MODID + "." + 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 + System.out.println("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 aItem, CreativeTabs p_150895_2_, List aList) { + for (int aMeta : mReverseEntityMap.values()) { + aList.add(ItemUtils.simpleMetaStack(aItem, aMeta, 1)); + } + } + + @Override + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(ItemStack par1ItemStack, int parColorType) { + int aID = par1ItemStack.getItemDamage(); + return (parColorType == 0) ? mColourBaseMap.get(aID) : mColourSpotsMap.get(aID); + } + + @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 " + mEntityNameMap.get(par1ItemStack.getItemDamage()); + } + + + @Override + public void registerIcons(final IIconRegister u) { + mIconMap.put(0, u.registerIcon(CORE.MODID + ":" + "spawn_egg")); + mIconMap.put(1, u.registerIcon(CORE.MODID + ":" + "spawn_egg_overlay")); + } + + @Override + public IIcon getIconFromDamageForRenderPass(final int damage, final int renderPass) { + return mIconMap.get(renderPass); + } + + @Override + public IIcon getIconFromDamage(int damage) { + return getIconFromDamageForRenderPass(0, 0); + } + + @Override + public IIcon getIcon(ItemStack aStack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) { + return getIconFromDamageForRenderPass(0, renderPass); + } + + @Override + public IIcon getIcon(ItemStack aStack, int renderPass) { + return getIconFromDamageForRenderPass(0, renderPass); + } + + @Override + public String getUnlocalizedName(ItemStack stack) { + return super.getUnlocalizedName() + "." + stack.getItemDamage(); + } + + public static void setEntityToSpawnName(int aMetaID, String parEntityToSpawnName) { + mEntityNameMap.put(aMetaID, parEntityToSpawnName); + mEntityFullNameMap.put(aMetaID, CORE.MODID + "." + parEntityToSpawnName); + } +} diff --git a/src/Java/gtPlusPlus/core/item/materials/DustDecayable.java b/src/Java/gtPlusPlus/core/item/materials/DustDecayable.java index 9994c7d362..d42ac85012 100644 --- a/src/Java/gtPlusPlus/core/item/materials/DustDecayable.java +++ b/src/Java/gtPlusPlus/core/item/materials/DustDecayable.java @@ -64,7 +64,7 @@ public class DustDecayable extends BaseItemTickable { } boolean a1, a2; - a1 = this.getIsActive(world, iStack); + a1 = this.isTicking(world, iStack); a2 = tickItemTag(world, iStack); if (!a1 && !a2) { diff --git a/src/Java/gtPlusPlus/core/proxy/ClientProxy.java b/src/Java/gtPlusPlus/core/proxy/ClientProxy.java index 2372762e0d..5344a46407 100644 --- a/src/Java/gtPlusPlus/core/proxy/ClientProxy.java +++ b/src/Java/gtPlusPlus/core/proxy/ClientProxy.java @@ -3,11 +3,7 @@ package gtPlusPlus.core.proxy; import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.common.Optional; -import cpw.mods.fml.common.event.FMLInitializationEvent; -import cpw.mods.fml.common.event.FMLLoadCompleteEvent; -import cpw.mods.fml.common.event.FMLPostInitializationEvent; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import cpw.mods.fml.common.event.FMLServerStartingEvent; +import cpw.mods.fml.common.event.*; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -17,43 +13,23 @@ import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.australia.entity.model.ModelBoar; import gtPlusPlus.australia.entity.model.ModelDingo; import gtPlusPlus.australia.entity.model.ModelOctopus; -import gtPlusPlus.australia.entity.render.RenderAustralianSpider; -import gtPlusPlus.australia.entity.render.RenderBoar; -import gtPlusPlus.australia.entity.render.RenderDingo; -import gtPlusPlus.australia.entity.render.RenderOctopus; -import gtPlusPlus.australia.entity.type.EntityAustralianSpiderBase; -import gtPlusPlus.australia.entity.type.EntityBoar; -import gtPlusPlus.australia.entity.type.EntityDingo; -import gtPlusPlus.australia.entity.type.EntityOctopus; +import gtPlusPlus.australia.entity.render.*; +import gtPlusPlus.australia.entity.type.*; +import gtPlusPlus.core.client.model.ModelEggBox; import gtPlusPlus.core.client.model.ModelGiantChicken; -import gtPlusPlus.core.client.renderer.CustomItemBlockRenderer; -import gtPlusPlus.core.client.renderer.CustomOreBlockRenderer; -import gtPlusPlus.core.client.renderer.RenderBatKing; -import gtPlusPlus.core.client.renderer.RenderDecayChest; -import gtPlusPlus.core.client.renderer.RenderGiantChicken; -import gtPlusPlus.core.client.renderer.RenderMiningExplosivesPrimed; -import gtPlusPlus.core.client.renderer.RenderPlasmaBolt; -import gtPlusPlus.core.client.renderer.RenderSickBlaze; -import gtPlusPlus.core.client.renderer.RenderStaballoyConstruct; -import gtPlusPlus.core.client.renderer.RenderToxinball; +import gtPlusPlus.core.client.renderer.*; import gtPlusPlus.core.common.CommonProxy; import gtPlusPlus.core.common.compat.COMPAT_PlayerAPI; import gtPlusPlus.core.entity.EntityPrimedMiningExplosive; import gtPlusPlus.core.entity.EntityTeslaTowerLightning; -import gtPlusPlus.core.entity.monster.EntityBatKing; -import gtPlusPlus.core.entity.monster.EntityGiantChickenBase; -import gtPlusPlus.core.entity.monster.EntitySickBlaze; -import gtPlusPlus.core.entity.monster.EntityStaballoyConstruct; -import gtPlusPlus.core.entity.projectile.EntityHydrofluoricAcidPotion; -import gtPlusPlus.core.entity.projectile.EntityLightningAttack; -import gtPlusPlus.core.entity.projectile.EntitySulfuricAcidPotion; -import gtPlusPlus.core.entity.projectile.EntityThrowableBomb; -import gtPlusPlus.core.entity.projectile.EntityToxinballSmall; +import gtPlusPlus.core.entity.monster.*; +import gtPlusPlus.core.entity.projectile.*; import gtPlusPlus.core.handler.render.FirepitRender; import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.lib.CORE.ConfigSwitches; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.tileentities.general.TileEntityDecayablesChest; +import gtPlusPlus.core.tileentities.general.TileEntityEggBox; import gtPlusPlus.core.tileentities.general.TileEntityFirepit; import gtPlusPlus.core.util.minecraft.particles.EntityParticleFXMysterious; import gtPlusPlus.xmod.gregtech.common.render.GTPP_CapeRenderer; @@ -153,6 +129,8 @@ public class ClientProxy extends CommonProxy implements Runnable{ ClientRegistry.bindTileEntitySpecialRenderer(TileEntityFirepit.class, new FirepitRender()); Logger.INFO("Registering Custom Renderer for the Lead Lined Chest."); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityDecayablesChest.class, new RenderDecayChest()); + Logger.INFO("Registering Custom Renderer for the Egg Box."); + //ClientRegistry.bindTileEntitySpecialRenderer(TileEntityEggBox.class, ModelEggBox.getRenderer()); //GT++ Australia diff --git a/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java b/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java index 2d389d8bb2..246bacca19 100644 --- a/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java +++ b/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java @@ -5,13 +5,7 @@ import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.general.BlockSuperLight.TileEntitySuperLight; import gtPlusPlus.core.block.machine.Machine_SuperJukebox.TileEntitySuperJukebox; import gtPlusPlus.core.lib.LoadedMods; -import gtPlusPlus.core.tileentities.general.TileEntityCircuitProgrammer; -import gtPlusPlus.core.tileentities.general.TileEntityDecayablesChest; -import gtPlusPlus.core.tileentities.general.TileEntityFirepit; -import gtPlusPlus.core.tileentities.general.TileEntityFishTrap; -import gtPlusPlus.core.tileentities.general.TileEntityInfiniteFluid; -import gtPlusPlus.core.tileentities.general.TileEntityPlayerDoorBase; -import gtPlusPlus.core.tileentities.general.TileEntityXpConverter; +import gtPlusPlus.core.tileentities.general.*; import gtPlusPlus.core.tileentities.machines.TileEntityAdvPooCollector; import gtPlusPlus.core.tileentities.machines.TileEntityModularityTable; import gtPlusPlus.core.tileentities.machines.TileEntityPestKiller; @@ -47,7 +41,7 @@ public class ModTileEntities { GameRegistry.registerTileEntity(TileEntitySuperLight.class, "TileEntitySuperLight"); GameRegistry.registerTileEntity(TileEntityPestKiller.class, "TileEntityPestKiller"); GameRegistry.registerTileEntity(TileEntityRoundRobinator.class, "TileEntityRoundRobinator"); - + GameRegistry.registerTileEntity(TileEntityEggBox.class, "TileEggBox"); //Mod TEs if (LoadedMods.Thaumcraft){ diff --git a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityDecayablesChest.java b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityDecayablesChest.java index c184b47d25..db93e9c4fc 100644 --- a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityDecayablesChest.java +++ b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityDecayablesChest.java @@ -90,14 +90,14 @@ public class TileEntityDecayablesChest extends TileEntity implements ISidedInven boolean a1, a2; int u = 0; - a1 = b.getIsActive(world, iStack); + a1 = b.isTicking(world, iStack); a2 = false; int SECONDS_TO_PROCESS = 1; while (u < (20 * SECONDS_TO_PROCESS)) { if (!a1) { break; } - a1 = b.getIsActive(world, iStack); + a1 = b.isTicking(world, iStack); a2 = b.tickItemTag(world, iStack); u++; } diff --git a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityEggBox.java b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityEggBox.java new file mode 100644 index 0000000000..0c428537cb --- /dev/null +++ b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityEggBox.java @@ -0,0 +1,359 @@ +package gtPlusPlus.core.tileentities.general; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.inventories.Inventory_EggBox; +import gtPlusPlus.core.item.general.ItemGiantEgg; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +public class TileEntityEggBox extends TileEntity implements ISidedInventory { + + private final Inventory_EggBox inventoryContents; + + /** Determines if the check for adjacent chests has taken place. */ + public boolean adjacentChestChecked; + /** Contains the chest tile located adjacent to this one (if any) */ + public TileEntityEggBox adjacentChestZNeg; + /** Contains the chest tile located adjacent to this one (if any) */ + public TileEntityEggBox adjacentChestXPos; + /** Contains the chest tile located adjacent to this one (if any) */ + public TileEntityEggBox adjacentChestXNeg; + /** Contains the chest tile located adjacent to this one (if any) */ + public TileEntityEggBox adjacentChestZPos; + /** The current angle of the lid (between 0 and 1) */ + public float lidAngle; + /** The angle of the lid last tick */ + public float prevLidAngle; + /** The number of players currently using this chest */ + public int numPlayersUsing; + + private String customName; + + private int cachedChestType; + private int tickCount = 0; + + public TileEntityEggBox() { + this.inventoryContents = new Inventory_EggBox(); + } + + public Inventory_EggBox getInventory() { + return this.inventoryContents; + } + + @Override + public void updateEntity() { + + // Try do chesty stuff + try { + this.updateEntityChest(); + } catch (Throwable t) { + + } + + try { + if (!this.worldObj.isRemote) { + this.tickCount++; + if ((this.tickCount % 10) == 0) { + cachedChestType = 1; + } + + if ((this.tickCount % 20) == 0) { + for (ItemStack inv : this.getInventory().getInventory()) { + if (inv == null) { + continue; + } + if (inv.getItem() instanceof ItemGiantEgg) { + ItemGiantEgg D = (ItemGiantEgg) inv.getItem(); + tryUpdateDecayable(D, inv, this.worldObj); + } + } + + } + updateSlots(); + } + } catch (final Throwable t) { + } + } + + public void tryUpdateDecayable(final ItemGiantEgg d, ItemStack iStack, final World world) { + if (world == null || iStack == null) { + return; + } + if (world.isRemote) { + return; + } + + boolean a1, a2; + int u = 0; + a1 = d.isTicking(world, iStack); + a2 = false; + int SECONDS_TO_PROCESS = 1; + while (u < (20 * SECONDS_TO_PROCESS)) { + if (!a1) { + break; + } + a1 = d.isTicking(world, iStack); + a2 = d.tickItemTag(world, iStack); + u++; + } + Logger.MACHINE_INFO("| "+d.getUnlocalizedName()+" | "+a1+"/"+a2); + + if (!a1 && !a2) { + ItemStack replacement = ItemUtils.getSimpleStack(d.getHatchResult(), 1); + replacement.stackSize = 1; + //iStack = replacement.copy(); + for (int fff = 0; fff < this.inventoryContents.getSizeInventory(); fff++) { + if (this.inventoryContents.getStackInSlot(fff) == iStack) { + this.inventoryContents.setInventorySlotContents(fff, replacement.copy()); + } + } + + updateSlots(); + this.inventoryContents. + markDirty(); + } + } + + public boolean anyPlayerInRange() { + return this.worldObj.getClosestPlayer(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, 32) != null; + } + + public NBTTagCompound getTag(final NBTTagCompound nbt, final String tag) { + if (!nbt.hasKey(tag)) { + nbt.setTag(tag, new NBTTagCompound()); + } + return nbt.getCompoundTag(tag); + } + + @Override + public void writeToNBT(final NBTTagCompound nbt) { + super.writeToNBT(nbt); + // Utils.LOG_WARNING("Trying to write NBT data to TE."); + final NBTTagCompound chestData = new NBTTagCompound(); + this.inventoryContents.writeToNBT(chestData); + nbt.setTag("ContentsChest", chestData); + if (this.hasCustomInventoryName()) { + nbt.setString("CustomName", this.getCustomName()); + } + } + + @Override + public void readFromNBT(final NBTTagCompound nbt) { + super.readFromNBT(nbt); + // Utils.LOG_WARNING("Trying to read NBT data from TE."); + this.inventoryContents.readFromNBT(nbt.getCompoundTag("ContentsChest")); + if (nbt.hasKey("CustomName", 8)) { + this.setCustomName(nbt.getString("CustomName")); + } + } + + @Override + public int getSizeInventory() { + return this.getInventory().getSizeInventory(); + } + + @Override + public ItemStack getStackInSlot(final int slot) { + return this.getInventory().getStackInSlot(slot); + } + + @Override + public ItemStack decrStackSize(final int slot, final int count) { + return this.getInventory().decrStackSize(slot, count); + } + + @Override + public ItemStack getStackInSlotOnClosing(final int slot) { + return this.getInventory().getStackInSlotOnClosing(slot); + } + + @Override + public void setInventorySlotContents(final int slot, final ItemStack stack) { + this.getInventory().setInventorySlotContents(slot, stack); + } + + @Override + public int getInventoryStackLimit() { + return this.getInventory().getInventoryStackLimit(); + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer entityplayer) { + return this.getInventory().isUseableByPlayer(entityplayer); + } + + @Override + public void openInventory() { + if (this.numPlayersUsing < 0) { + this.numPlayersUsing = 0; + } + if (!this.worldObj.isRemote) { + this.numPlayersUsing++; + cachedChestType = 1; + } + this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, this.numPlayersUsing); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); + this.getInventory().openInventory(); + } + + @Override + public void closeInventory() { + if (!this.worldObj.isRemote) { + this.numPlayersUsing--; + cachedChestType = 1; + } + this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, this.numPlayersUsing); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); + this.getInventory().closeInventory(); + } + + @Override + public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { + return this.getInventory().isItemValidForSlot(slot, itemstack); + } + + @Override + public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { + final int[] accessibleSides = new int[this.getSizeInventory()]; + for (int r = 0; r < this.getInventory().getSizeInventory(); r++) { + accessibleSides[r] = r; + } + return accessibleSides; + + } + + @Override + public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) { + return this.getInventory().isItemValidForSlot(0, p_102007_2_); + } + + @Override + public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { + return this.getInventory().isItemValidForSlot(0, p_102008_2_); + } + + public String getCustomName() { + return this.customName; + } + + public void setCustomName(final String customName) { + this.customName = customName; + } + + @Override + public String getInventoryName() { + return this.hasCustomInventoryName() ? this.customName : "container.EggBox"; + } + + @Override + public boolean hasCustomInventoryName() { + return (this.customName != null) && !this.customName.equals(""); + } + + /** + * Causes the TileEntity to reset all it's cached values for it's container + * Block, metadata and in the case of chests, the adjacent chest check + */ + public void updateContainingBlockInfo() { + super.updateContainingBlockInfo(); + this.adjacentChestChecked = false; + } + + /** + * Performs the check for adjacent chests to determine if this chest is double + * or not. + */ + public void checkForAdjacentChests() { + if (!this.adjacentChestChecked) { + this.adjacentChestChecked = true; + this.adjacentChestZNeg = null; + this.adjacentChestXPos = null; + this.adjacentChestXNeg = null; + this.adjacentChestZPos = null; + } + } + + public void updateEntityChest() { + float f; + this.prevLidAngle = this.lidAngle; + f = 0.04F; + double d2; + if (this.numPlayersUsing > 0 && this.lidAngle == 0.0F && this.adjacentChestZNeg == null + && this.adjacentChestXNeg == null) { + double d1 = (double) this.xCoord + 0.5D; + d2 = (double) this.zCoord + 0.5D; + this.worldObj.playSoundEffect(d1, (double) this.yCoord + 0.5D, d2, "random.chestopen", 0.5F, + this.worldObj.rand.nextFloat() * 0.1F + 0.9F); + } + + if (this.numPlayersUsing == 0 && this.lidAngle > 0.0F || this.numPlayersUsing > 0 && this.lidAngle < 1.0F) { + float f1 = this.lidAngle; + if (this.numPlayersUsing > 0) { + //this.lidAngle += f; + this.lidAngle += (float) (f * (1 + 0.10 * 0.01)); + } else { + //this.lidAngle -= f; + this.lidAngle -= (float) (f * (1 + 0.10 * 0.01)); + } + if (this.lidAngle > 1.0F) { + this.lidAngle = 1.0F; + } + float f2 = 0.5F; + if (this.lidAngle < f2 && f1 >= f2 && this.adjacentChestZNeg == null && this.adjacentChestXNeg == null) { + d2 = (double) this.xCoord + 0.5D; + double d0 = (double) this.zCoord + 0.5D; + this.worldObj.playSoundEffect(d2, (double) this.yCoord + 0.5D, d0, "random.chestclosed", 0.5F, + this.worldObj.rand.nextFloat() * 0.1F + 0.9F); + } + + if (this.lidAngle < 0.0F) { + this.lidAngle = 0.0F; + } + } + } + + /** + * Called when a client event is received with the event number and argument, + * see World.sendClientEvent + */ + public boolean receiveClientEvent(int p_145842_1_, int p_145842_2_) { + if (p_145842_1_ == 1) + { + this.numPlayersUsing = p_145842_2_; + return true; + } + else + { + return super.receiveClientEvent(p_145842_1_, p_145842_2_); + } + } + + /** + * invalidates a tile entity + */ + public final void invalidate() { + super.invalidate(); + cachedChestType = 1; + this.updateContainingBlockInfo(); + this.checkForAdjacentChests(); + } + + private final int updateSlots() { + //Have slots changed? + if (cachedChestType == 0) { + return 0; + } + ItemUtils.organiseInventory(getInventory()); + cachedChestType = 0; + return cachedChestType; + + } + +} diff --git a/src/Java/gtPlusPlus/nei/DecayableRecipeHandler.java b/src/Java/gtPlusPlus/nei/DecayableRecipeHandler.java index dae1a663d7..ce2062d12c 100644 --- a/src/Java/gtPlusPlus/nei/DecayableRecipeHandler.java +++ b/src/Java/gtPlusPlus/nei/DecayableRecipeHandler.java @@ -23,6 +23,8 @@ import net.minecraft.util.StatCollector; public class DecayableRecipeHandler extends TemplateRecipeHandler { + public static final String mNEIName = "Decayables"; + public String getRecipeName() { return StatCollector.translateToLocal("GTPP.container.decaychest.name"); } diff --git a/src/Java/gtPlusPlus/nei/NEI_GT_Config.java b/src/Java/gtPlusPlus/nei/NEI_GT_Config.java index 514612752d..bfe580099a 100644 --- a/src/Java/gtPlusPlus/nei/NEI_GT_Config.java +++ b/src/Java/gtPlusPlus/nei/NEI_GT_Config.java @@ -7,17 +7,18 @@ import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GTPP_Recipe; import gregtech.api.util.GTPP_Recipe.GTPP_Recipe_Map; import gregtech.nei.GT_NEI_DefaultHandler; +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; public class NEI_GT_Config implements IConfigureNEI { - public static boolean sIsAdded = true; + + public static boolean sIsAdded = false; private static final AutoMap<String> mUniqueRecipeMapHandling = new AutoMap<String>(); - + @Override public synchronized void loadConfig() { - sIsAdded = false; mUniqueRecipeMapHandling.add(GTPP_Recipe_Map.sChemicalPlantRecipes.mUnlocalizedName); mUniqueRecipeMapHandling.add(GTPP_Recipe_Map.sOreMillRecipes.mUnlocalizedName); @@ -25,36 +26,63 @@ implements IConfigureNEI { mUniqueRecipeMapHandling.add(GTPP_Recipe_Map.sVacuumFurnaceRecipes.mUnlocalizedName); // Custom Recipe Maps + Logger.INFO("NEI Registration: "+CustomRecipeMap.sMappings.size()+" CustomRecipeMaps"); for (final CustomRecipeMap tMap : CustomRecipeMap.sMappings) { if (tMap.mNEIAllowed) { + Logger.INFO("NEI Registration: Registering NEI handler for "+tMap.mNEIName); new GTPP_NEI_CustomMapHandler(tMap); } + else { + Logger.INFO("NEI Registration: Not allowed to register NEI handler for "+tMap.mNEIName); + } } // Custom Recipe maps + Logger.INFO("NEI Registration: "+CustomRecipeMap.sMappings.size()+" sMappings"); for (final GTPP_Recipe_Map tMap : GTPP_Recipe.GTPP_Recipe_Map.sMappings) { if (tMap.mNEIAllowed) { if (!mUniqueRecipeMapHandling.contains(tMap.mUnlocalizedName)) { + Logger.INFO("NEI Registration: Registering NEI handler for "+tMap.mNEIName); new GTPP_NEI_DefaultHandler(tMap); - } + } + else { + Logger.INFO("NEI Registration: Not allowed to register NEI handler for "+tMap.mNEIName); + } + } + else { + Logger.INFO("NEI Registration: Skipping registration of NEI handler for "+tMap.mNEIName); + } } // Standard GT Recipe Maps + Logger.INFO("NEI Registration: "+GTPP_Recipe.GTPP_Recipe_Map_Internal.sMappingsEx.size()+" sMappingEx"); for (final GT_Recipe_Map tMap : GTPP_Recipe.GTPP_Recipe_Map_Internal.sMappingsEx) { if (tMap.mNEIAllowed) { if (!mUniqueRecipeMapHandling.contains(tMap.mUnlocalizedName)) { + Logger.INFO("NEI Registration: Registering NEI handler for "+tMap.mNEIName); new GT_NEI_DefaultHandler(tMap); - } + } + else { + Logger.INFO("NEI Registration: Not allowed to register NEI handler for "+tMap.mNEIName); + } + } + else { + Logger.INFO("NEI Registration: Skipping registration of NEI handler for "+tMap.mNEIName); } } + Logger.INFO("NEI Registration: Registering NEI handler for "+GTPP_Recipe.GTPP_Recipe_Map.sChemicalPlantRecipes.mNEIName); new GT_NEI_FluidReactor(); + Logger.INFO("NEI Registration: Registering NEI handler for "+GTPP_Recipe.GTPP_Recipe_Map.sOreMillRecipes.mNEIName); new GT_NEI_MillingMachine(); + Logger.INFO("NEI Registration: Registering NEI handler for "+GTPP_Recipe.GTPP_Recipe_Map.sFlotationCellRecipes.mNEIName); new GT_NEI_FlotationCell(); + Logger.INFO("NEI Registration: Registering NEI handler for "+GTPP_Recipe.GTPP_Recipe_Map.sVacuumFurnaceRecipes.mNEIName); new GT_NEI_VacFurnace(); - sIsAdded = true; + Logger.INFO("NEI Registration: Registering NEI handler for "+DecayableRecipeHandler.mNEIName); API.registerRecipeHandler(new DecayableRecipeHandler()); API.registerUsageHandler(new DecayableRecipeHandler()); + sIsAdded = true; } @Override @@ -64,6 +92,6 @@ implements IConfigureNEI { @Override public String getVersion() { - return "(1.01)"; + return "(1.12)"; } } diff --git a/src/resources/assets/miscutils/lang/en_US.lang b/src/resources/assets/miscutils/lang/en_US.lang index df6fbaa5b3..a7746a06f8 100644 --- a/src/resources/assets/miscutils/lang/en_US.lang +++ b/src/resources/assets/miscutils/lang/en_US.lang @@ -3179,4 +3179,13 @@ item.FrothAlmandineflotation.name=Almandine Flotation Froth Cell item.FrothPyropeflotation.name=Pyrope Flotation Froth Cell //Added 13/04/20 -item.T3RecipeSelector.name=Programmed Breakthrough Circuit
\ No newline at end of file +item.T3RecipeSelector.name=Programmed Breakthrough Circuit + +//Added 03/05/20 +entity.miscutils.batKing.name=Spectral Bat +entity.miscutils.bigChickenFriendly.name=Giant Chicken +entity.miscutils.AusDingo.name=Dingo +entity.miscutils.AusBoar.name=Wild Boar +entity.miscutils.AusSpider.name=Forest Spider +entity.miscutils.AusOctopus.name=Octopus +container.EggBox=Egg Hatching Box
\ No newline at end of file diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/EggBox_full.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/EggBox_full.png Binary files differnew file mode 100644 index 0000000000..787572ea3b --- /dev/null +++ b/src/resources/assets/miscutils/textures/blocks/TileEntities/EggBox_full.png diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/EggBox_side.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/EggBox_side.png Binary files differnew file mode 100644 index 0000000000..771fef125a --- /dev/null +++ b/src/resources/assets/miscutils/textures/blocks/TileEntities/EggBox_side.png diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/EggBox_top.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/EggBox_top.png Binary files differnew file mode 100644 index 0000000000..d766cc9f3f --- /dev/null +++ b/src/resources/assets/miscutils/textures/blocks/TileEntities/EggBox_top.png |