From 5d66e0d739e82dfe4c57f080600f5b6ff638146a Mon Sep 17 00:00:00 2001 From: mDiyo Date: Tue, 25 Jun 2013 07:37:51 -0700 Subject: [PATCH] Tooltips on Smeltery Gui, Fix tools not harvesting mod blocks properly and potion effects staying around --- mods/tinker/resources/lang/en_US.xml | 1 + mods/tinker/resources/manuals/materials.xml | 2 +- mods/tinker/tconstruct/TConstruct.java | 7 +- mods/tinker/tconstruct/blocks/Aggregator.java | 57 +- .../tconstruct/blocks/LightCrystalBase.java | 23 +- .../tinker/tconstruct/blocks/SearedBlock.java | 2 - .../tconstruct/blocks/ToolStationBlock.java | 335 +++-- .../blocks/logic/CastingBasinLogic.java | 2 +- .../blocks/logic/CastingTableLogic.java | 2 +- .../blocks/logic/GlowstoneAggregator.java | 2 +- .../blocks/logic/SmelteryLogic.java | 60 +- .../tconstruct/client/BattleaxeRenderer.java | 27 - .../tconstruct/client/TClientEvents.java | 14 +- .../tconstruct/client/TProxyClient.java | 10 +- .../client/entity/CrystalGuardianRender.java | 188 +++ .../client/entity/CrystalRender.java | 164 --- .../client/entity/SlimeCloneRender.java | 2 +- .../tconstruct/client/gui/SmelteryGui.java | 205 ++- .../client/gui/StencilTableGui.java | 14 +- mods/tinker/tconstruct/common/TContent.java | 43 +- .../tconstruct/crystal/TheftValueTracker.java | 22 + mods/tinker/tconstruct/entity/Automaton.java | 49 +- mods/tinker/tconstruct/entity/Crystal.java | 21 - .../tconstruct/entity/CrystalGuardian.java | 21 + mods/tinker/tconstruct/entity/GolemBase.java | 571 +++++--- mods/tinker/tconstruct/entity/SlimeClone.java | 19 +- .../tconstruct/entity/ai/GAIAttackTarget.java | 142 ++ .../tconstruct/entity/ai/GAIFindTarget.java | 195 +++ .../tconstruct/entity/ai/GAIFollowOwner.java | 114 ++ .../tconstruct/entity/ai/GolemAIBase.java | 23 + .../tinker/tconstruct/entity/ai/TaskBase.java | 40 - .../tconstruct/entity/ai/TaskClearcut.java | 52 - .../tinker/tconstruct/entity/ai/TaskWait.java | 17 - .../tinker/tconstruct/items/CraftingItem.java | 3 +- mods/tinker/tconstruct/items/GoldenHead.java | 83 ++ .../tconstruct/items/tools/Battleaxe.java | 10 +- .../tconstruct/items/tools/Excavator.java | 64 +- .../tinker/tconstruct/items/tools/Hammer.java | 159 +-- .../tconstruct/items/tools/LumberAxe.java | 61 +- .../tinker/tconstruct/items/tools/Scythe.java | 10 +- .../tconstruct/library/ActiveToolMod.java | 6 +- .../library/TConstructRegistry.java | 4 +- .../library/blocks/InventoryBlock.java | 4 +- .../library/crafting/CastingRecipe.java | 4 +- .../library/crafting/LiquidCasting.java | 5 + .../library/tools/AbilityHelper.java | 1210 +++++++++-------- .../tconstruct/library/tools/ToolCore.java | 66 +- .../library/util/ChunkCoordTuple.java | 51 + .../tconstruct/modifiers/TActiveOmniMod.java | 6 +- mods/tinker/tconstruct/util/PHConstruct.java | 30 + .../tinker/tconstruct/util/RecipeRemover.java | 20 + .../tinker/tconstruct/util/TEventHandler.java | 249 ++-- .../tconstruct/util/player/TFoodStats.java | 4 +- .../util/player/TPlayerHandler.java | 7 + .../worldgen/TBaseWorldGenerator.java | 40 + mods/tinker/textures/blocks/amber_crystal.png | Bin 0 -> 346 bytes .../tinker/textures/items/skull_char_gold.png | Bin 0 -> 406 bytes mods/tinker/textures/mob/Credits.txt | 3 +- .../textures/mob/crystalGuardMorganite.png | Bin 0 -> 1773 bytes .../textures/mob/crystalGuardTurquoise.png | Bin 0 -> 1764 bytes .../tinker/textures/mob/crystalguardamber.png | Bin 0 -> 1760 bytes sparrow/ISparrow.java | 75 + test/XinStick.java | 5 +- 63 files changed, 2990 insertions(+), 1635 deletions(-) delete mode 100644 mods/tinker/tconstruct/client/BattleaxeRenderer.java create mode 100644 mods/tinker/tconstruct/client/entity/CrystalGuardianRender.java delete mode 100644 mods/tinker/tconstruct/client/entity/CrystalRender.java create mode 100644 mods/tinker/tconstruct/crystal/TheftValueTracker.java delete mode 100644 mods/tinker/tconstruct/entity/Crystal.java create mode 100644 mods/tinker/tconstruct/entity/CrystalGuardian.java create mode 100644 mods/tinker/tconstruct/entity/ai/GAIAttackTarget.java create mode 100644 mods/tinker/tconstruct/entity/ai/GAIFindTarget.java create mode 100644 mods/tinker/tconstruct/entity/ai/GAIFollowOwner.java create mode 100644 mods/tinker/tconstruct/entity/ai/GolemAIBase.java delete mode 100644 mods/tinker/tconstruct/entity/ai/TaskBase.java delete mode 100644 mods/tinker/tconstruct/entity/ai/TaskClearcut.java delete mode 100644 mods/tinker/tconstruct/entity/ai/TaskWait.java create mode 100644 mods/tinker/tconstruct/items/GoldenHead.java create mode 100644 mods/tinker/tconstruct/library/util/ChunkCoordTuple.java create mode 100644 mods/tinker/textures/blocks/amber_crystal.png create mode 100644 mods/tinker/textures/items/skull_char_gold.png create mode 100644 mods/tinker/textures/mob/crystalGuardMorganite.png create mode 100644 mods/tinker/textures/mob/crystalGuardTurquoise.png create mode 100644 mods/tinker/textures/mob/crystalguardamber.png create mode 100644 sparrow/ISparrow.java diff --git a/mods/tinker/resources/lang/en_US.xml b/mods/tinker/resources/lang/en_US.xml index 14b1a0e..a93c4e5 100644 --- a/mods/tinker/resources/lang/en_US.xml +++ b/mods/tinker/resources/lang/en_US.xml @@ -96,6 +96,7 @@ Aluminum Oreberry Silver Oreberry + Golden Head Spawn Paper Stack diff --git a/mods/tinker/resources/manuals/materials.xml b/mods/tinker/resources/manuals/materials.xml index 79d172c..55c2828 100644 --- a/mods/tinker/resources/manuals/materials.xml +++ b/mods/tinker/resources/manuals/materials.xml @@ -442,7 +442,7 @@ Class: Heavy Melee Weapon - Reinforced: 10% chance per level of not using durability - Stonebound: The tool mines faster as it wears out, but does less damage -- Spiny: The tool mines does more damage as it wears out, but mines slower +- Spiny: The tool attacks with does more damage as it wears out, but mines slower - Writable: One extra modifier per piece diff --git a/mods/tinker/tconstruct/TConstruct.java b/mods/tinker/tconstruct/TConstruct.java index aa27452..fb542cf 100644 --- a/mods/tinker/tconstruct/TConstruct.java +++ b/mods/tinker/tconstruct/TConstruct.java @@ -38,7 +38,7 @@ import cpw.mods.fml.common.registry.VillagerRegistry; * @dependencies: IC2 API, MFR API */ -@Mod(modid = "TConstruct", name = "TConstruct", version = "1.5.1_1.3.5", dependencies = "required-after:Forge@[7.7.1.675,)") +@Mod(modid = "TConstruct", name = "TConstruct", version = "1.5.1_1.3.6.2", dependencies = "required-after:Forge@[7.7.1.675,)") @NetworkMod(serverSideRequired = false, clientSideRequired = true, channels = { "TConstruct" }, packetHandler = mods.tinker.tconstruct.util.network.TPacketHandler.class) public class TConstruct { @@ -52,6 +52,11 @@ public class TConstruct /* Proxies for sides, used for graphics processing */ @SidedProxy(clientSide = "mods.tinker.tconstruct.client.TProxyClient", serverSide = "mods.tinker.tconstruct.common.TProxyCommon") public static TProxyCommon proxy; + + public TConstruct() + { + System.out.println("[TConstruct] Preparing to take over the world"); + } @PreInit public void preInit (FMLPreInitializationEvent evt) diff --git a/mods/tinker/tconstruct/blocks/Aggregator.java b/mods/tinker/tconstruct/blocks/Aggregator.java index ae70657..cc4614a 100644 --- a/mods/tinker/tconstruct/blocks/Aggregator.java +++ b/mods/tinker/tconstruct/blocks/Aggregator.java @@ -5,23 +5,27 @@ import java.util.List; import mods.tinker.tconstruct.TConstruct; import mods.tinker.tconstruct.blocks.logic.GlowstoneAggregator; import mods.tinker.tconstruct.common.TProxyCommon; +import mods.tinker.tconstruct.crystal.TheftValueTracker; import mods.tinker.tconstruct.library.TConstructRegistry; import mods.tinker.tconstruct.library.blocks.InventoryBlock; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EntityLiving; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Icon; +import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class Aggregator extends InventoryBlock { - public String[] textureNames = { "glowstone_top", "glowstone_top_inactive", "glowstone_side", "glowstone_bottom"}; + public String[] textureNames = { "glowstone_top", "glowstone_top_inactive", "glowstone_side", "glowstone_bottom" }; public Icon[] icons; + public Aggregator(int id) { super(id, Material.iron); @@ -35,37 +39,33 @@ public class Aggregator extends InventoryBlock { return meta; } - + @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister iconRegister) + public void registerIcons (IconRegister iconRegister) { this.icons = new Icon[textureNames.length]; for (int i = 0; i < this.icons.length; ++i) { - this.icons[i] = iconRegister.registerIcon("tinker:machines/aggregator_"+textureNames[i]); + this.icons[i] = iconRegister.registerIcon("tinker:machines/aggregator_" + textureNames[i]); } } - - /*@Override - public Icon getBlockTexture(IBlockAccess iblockaccess, int x, int y, int z, int side) - { - if (iblockaccess instanceof World) + + @Override + public Icon getBlockTexture (IBlockAccess iblockaccess, int x, int y, int z, int side) + { + if (side == 1) { - System.out.println("Rawr!"); - World world = (World) iblockaccess; - if (world.canBlockSeeTheSky(x, y, z)) - { - int level = world.getSavedLightValue(EnumSkyBlock.Sky, x, y, z) - world.skylightSubtracted; - System.out.println("Level: "+level); - if (level < 12) - return icons[1]; - } + GlowstoneAggregator logic = (GlowstoneAggregator) iblockaccess.getBlockTileEntity(x, y, z); + if (logic.currentLightLevel >= 12) + return icons[0]; + else + return icons[1]; } - return this.getIcon(side, iblockaccess.getBlockMetadata(x, y, z)); - }*/ - + return this.getIcon(side, iblockaccess.getBlockMetadata(x, y, z)); + } + @Override @SideOnly(Side.CLIENT) public Icon getIcon (int side, int meta) @@ -78,6 +78,21 @@ public class Aggregator extends InventoryBlock //return icons[meta]; } + @Override + public void onBlockPlacedBy (World world, int x, int y, int z, EntityLiving entityliving, ItemStack stack) + { + super.onBlockPlacedBy(world, x, y, z, entityliving, stack); + if (!world.isRemote) + TheftValueTracker.updateCrystallinity(x, z, world.provider.dimensionId, 4); + } + + @Override + public void breakBlock (World world, int x, int y, int z, int par5, int par6) + { + super.breakBlock(world, x, y, z, par5, par6); + TheftValueTracker.updateCrystallinity(x, z, world.provider.dimensionId, -4); + } + @Override public void getSubBlocks (int id, CreativeTabs tab, List list) { diff --git a/mods/tinker/tconstruct/blocks/LightCrystalBase.java b/mods/tinker/tconstruct/blocks/LightCrystalBase.java index 1350339..9f77fdb 100644 --- a/mods/tinker/tconstruct/blocks/LightCrystalBase.java +++ b/mods/tinker/tconstruct/blocks/LightCrystalBase.java @@ -7,12 +7,16 @@ import mods.tinker.tconstruct.client.block.CrystalBlockRender; import mods.tinker.tconstruct.library.TConstructRegistry; import net.minecraft.block.Block; import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.ItemStack; import net.minecraft.util.Icon; public class LightCrystalBase extends Block { + String[] textureNames = { "amber_crystal" }; + Icon[] icons; + public LightCrystalBase(int id) { super(id, Material.glass); @@ -23,8 +27,10 @@ public class LightCrystalBase extends Block public Icon getIcon (int side, int meta) { if (meta < 5) - return Block.cake.getIcon(side, meta); - return Block.sponge.getIcon(side, 1); + return Block.glowStone.getIcon(side, meta); + if (meta < 10) + return Block.blockNetherQuartz.getIcon(side, 1); + return icons[0]; } @Override @@ -48,9 +54,20 @@ public class LightCrystalBase extends Block @Override public void getSubBlocks (int id, CreativeTabs tab, List list) { - for (int iter = 0; iter < 10; iter++) + for (int iter = 0; iter < 15; iter++) { list.add(new ItemStack(id, 1, iter)); } } + + @Override + public void registerIcons (IconRegister iconRegister) + { + this.icons = new Icon[textureNames.length]; + + for (int i = 0; i < this.icons.length; ++i) + { + this.icons[i] = iconRegister.registerIcon("tinker:" + textureNames[i]); + } + } } diff --git a/mods/tinker/tconstruct/blocks/SearedBlock.java b/mods/tinker/tconstruct/blocks/SearedBlock.java index 800fa0e..f4fc3e3 100644 --- a/mods/tinker/tconstruct/blocks/SearedBlock.java +++ b/mods/tinker/tconstruct/blocks/SearedBlock.java @@ -90,7 +90,6 @@ public class SearedBlock extends InventoryBlock { if (!world.isRemote) { - //System.out.println("Castses"); CastingTableLogic logic = (CastingTableLogic) world.getBlockTileEntity(x, y, z); if (logic.liquid != null) return true; @@ -126,7 +125,6 @@ public class SearedBlock extends InventoryBlock { if (!world.isRemote) { - //System.out.println("Castses"); CastingBasinLogic logic = (CastingBasinLogic) world.getBlockTileEntity(x, y, z); if (logic.liquid != null) return true; diff --git a/mods/tinker/tconstruct/blocks/ToolStationBlock.java b/mods/tinker/tconstruct/blocks/ToolStationBlock.java index fec7977..0a5f081 100644 --- a/mods/tinker/tconstruct/blocks/ToolStationBlock.java +++ b/mods/tinker/tconstruct/blocks/ToolStationBlock.java @@ -8,11 +8,14 @@ import mods.tinker.tconstruct.blocks.logic.PatternChestLogic; import mods.tinker.tconstruct.blocks.logic.StencilTableLogic; import mods.tinker.tconstruct.blocks.logic.ToolStationLogic; import mods.tinker.tconstruct.client.block.TableRender; +import mods.tinker.tconstruct.common.TContent; import mods.tinker.tconstruct.library.TConstructRegistry; import mods.tinker.tconstruct.library.blocks.InventoryBlock; +import mods.tinker.tconstruct.util.PHConstruct; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EntityLiving; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; @@ -22,188 +25,182 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class ToolStationBlock extends InventoryBlock -{ - public ToolStationBlock(int id, Material material) - { - super(id, material); - this.setCreativeTab(TConstructRegistry.blockTab); - this.setHardness(2f); +{ + public ToolStationBlock(int id, Material material) + { + super(id, material); + this.setCreativeTab(TConstructRegistry.blockTab); + this.setHardness(2f); this.setStepSound(Block.soundWoodFootstep); - } + } - //Block.hasComparatorInputOverride and Block.getComparatorInputOverride - - /* Rendering */ - @Override - public String[] getTextureNames() - { - String[] textureNames = { - "toolstation_top", - "toolstation_side", - "toolstation_bottom", - "partbuilder_oak_top", - "partbuilder_oak_side", - "partbuilder_oak_bottom", - "partbuilder_spruce_top", - "partbuilder_spruce_side", - "partbuilder_spruce_bottom", - "partbuilder_birch_top", - "partbuilder_birch_side", - "partbuilder_birch_bottom", - "partbuilder_jungle_top", - "partbuilder_jungle_side", - "partbuilder_jungle_bottom", - "patternchest_top", - "patternchest_side", - "patternchest_bottom", - "stenciltable_oak_top", - "stenciltable_oak_side", - "stenciltable_oak_bottom", - "stenciltable_spruce_top", - "stenciltable_spruce_side", - "stenciltable_spruce_bottom", - "stenciltable_birch_top", - "stenciltable_birch_side", - "stenciltable_birch_bottom", - "stenciltable_jungle_top", - "stenciltable_jungle_side", - "stenciltable_jungle_bottom"}; - - return textureNames; - } - - @Override - public Icon getIcon (int side, int meta) - { - if (meta <= 4) - { - return icons[meta*3+getTextureIndex(side)]; - } - else if (meta <= 9) - { - return icons[15+getTextureIndex(side)]; - } - else - { - return icons[meta*3+getTextureIndex(side)-12]; - } - } + //Block.hasComparatorInputOverride and Block.getComparatorInputOverride - public int getTextureIndex (int side) - { - if (side == 0) - return 2; - if (side == 1) - return 0; + /* Rendering */ + @Override + public String[] getTextureNames () + { + String[] textureNames = { "toolstation_top", "toolstation_side", "toolstation_bottom", "partbuilder_oak_top", "partbuilder_oak_side", "partbuilder_oak_bottom", "partbuilder_spruce_top", + "partbuilder_spruce_side", "partbuilder_spruce_bottom", "partbuilder_birch_top", "partbuilder_birch_side", "partbuilder_birch_bottom", "partbuilder_jungle_top", + "partbuilder_jungle_side", "partbuilder_jungle_bottom", "patternchest_top", "patternchest_side", "patternchest_bottom", "stenciltable_oak_top", "stenciltable_oak_side", + "stenciltable_oak_bottom", "stenciltable_spruce_top", "stenciltable_spruce_side", "stenciltable_spruce_bottom", "stenciltable_birch_top", "stenciltable_birch_side", + "stenciltable_birch_bottom", "stenciltable_jungle_top", "stenciltable_jungle_side", "stenciltable_jungle_bottom" }; - return 1; - } + return textureNames; + } - @Override - public boolean renderAsNormalBlock () - { - return false; - } + @Override + public Icon getIcon (int side, int meta) + { + if (meta <= 4) + { + return icons[meta * 3 + getTextureIndex(side)]; + } + else if (meta <= 9) + { + return icons[15 + getTextureIndex(side)]; + } + else + { + return icons[meta * 3 + getTextureIndex(side) - 12]; + } + } - @Override - public boolean isOpaqueCube () - { - return false; - } + public int getTextureIndex (int side) + { + if (side == 0) + return 2; + if (side == 1) + return 0; - @Override - public int getRenderType () - { - return TableRender.tabelModelID; - } + return 1; + } - @Override - public boolean shouldSideBeRendered (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) - { - return true; - } + @Override + public boolean renderAsNormalBlock () + { + return false; + } - public AxisAlignedBB getSelectedBoundingBoxFromPool (World world, int x, int y, int z) - { - int metadata = world.getBlockMetadata(x, y, z); - if (metadata == 5) - return AxisAlignedBB.getAABBPool().getAABB((double) x + this.minX, (double) y + this.minY, (double) z + this.minZ, (double) x + this.maxX, (double) y + this.maxY - 0.125, (double) z + this.maxZ); - return AxisAlignedBB.getAABBPool().getAABB((double) x + this.minX, (double) y + this.minY, (double) z + this.minZ, (double) x + this.maxX, (double) y + this.maxY, (double) z + this.maxZ); - } + @Override + public boolean isOpaqueCube () + { + return false; + } - @Override - public TileEntity createTileEntity (World world, int metadata) - { - switch (metadata) - { - case 0: - return new ToolStationLogic(); - case 1: - return new PartCrafterLogic(); - case 2: - return new PartCrafterLogic(); - case 3: - return new PartCrafterLogic(); - case 4: - return new PartCrafterLogic(); - case 5: - return new PatternChestLogic(); - case 6: - return new PatternChestLogic(); - case 7: - return new PatternChestLogic(); - case 8: - return new PatternChestLogic(); - case 9: - return new PatternChestLogic(); - case 10: - return new StencilTableLogic(); - case 11: - return new StencilTableLogic(); - case 12: - return new StencilTableLogic(); - case 13: - return new StencilTableLogic(); - /*case 14: - return new CastingTableLogic();*/ - default: - return null; - } - } + @Override + public int getRenderType () + { + return TableRender.tabelModelID; + } - @Override - public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer) - { - int md = world.getBlockMetadata(x, y, z); - if (md == 0) - return 0; - else if (md < 5) - return 1; - else if (md < 10) - return 2; - else - return 3; + @Override + public boolean shouldSideBeRendered (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) + { + return true; + } - //return -1; - } + public AxisAlignedBB getSelectedBoundingBoxFromPool (World world, int x, int y, int z) + { + int metadata = world.getBlockMetadata(x, y, z); + if (metadata == 5) + return AxisAlignedBB.getAABBPool().getAABB((double) x + this.minX, (double) y + this.minY, (double) z + this.minZ, (double) x + this.maxX, (double) y + this.maxY - 0.125, + (double) z + this.maxZ); + return AxisAlignedBB.getAABBPool().getAABB((double) x + this.minX, (double) y + this.minY, (double) z + this.minZ, (double) x + this.maxX, (double) y + this.maxY, (double) z + this.maxZ); + } - @Override - public Object getModInstance () - { - return TConstruct.instance; - } + @Override + public TileEntity createTileEntity (World world, int metadata) + { + switch (metadata) + { + case 0: + return new ToolStationLogic(); + case 1: + return new PartCrafterLogic(); + case 2: + return new PartCrafterLogic(); + case 3: + return new PartCrafterLogic(); + case 4: + return new PartCrafterLogic(); + case 5: + return new PatternChestLogic(); + case 6: + return new PatternChestLogic(); + case 7: + return new PatternChestLogic(); + case 8: + return new PatternChestLogic(); + case 9: + return new PatternChestLogic(); + case 10: + return new StencilTableLogic(); + case 11: + return new StencilTableLogic(); + case 12: + return new StencilTableLogic(); + case 13: + return new StencilTableLogic(); + /*case 14: + return new CastingTableLogic();*/ + default: + return null; + } + } - @Override - public void getSubBlocks (int id, CreativeTabs tab, List list) - { - for (int iter = 0; iter < 6; iter++) - { - list.add(new ItemStack(id, 1, iter)); - } + @Override + public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer) + { + int md = world.getBlockMetadata(x, y, z); + if (md == 0) + return 0; + else if (md < 5) + return 1; + else if (md < 10) + return 2; + else + return 3; - for (int iter = 10; iter < 14; iter++) - { - list.add(new ItemStack(id, 1, iter)); - } - } + //return -1; + } + + @Override + public Object getModInstance () + { + return TConstruct.instance; + } + + @Override + public void getSubBlocks (int id, CreativeTabs tab, List list) + { + for (int iter = 0; iter < 6; iter++) + { + list.add(new ItemStack(id, 1, iter)); + } + + for (int iter = 10; iter < 14; iter++) + { + list.add(new ItemStack(id, 1, iter)); + } + } + + //public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving, ItemStack par6ItemStack) {} + @Override + public void onBlockPlacedBy (World world, int x, int y, int z, EntityLiving par5EntityLiving, ItemStack par6ItemStack) + { + if (PHConstruct.freePatterns) + { + int meta = world.getBlockMetadata(x, y, z); + if (meta == 5) + { + PatternChestLogic logic = (PatternChestLogic) world.getBlockTileEntity(x, y, z); + for (int i = 1; i <= 13; i++) + { + logic.setInventorySlotContents(i - 1, new ItemStack(TContent.woodPattern, 1, i)); + } + logic.setInventorySlotContents(13, new ItemStack(TContent.woodPattern, 1, 22)); + } + } + } } diff --git a/mods/tinker/tconstruct/blocks/logic/CastingBasinLogic.java b/mods/tinker/tconstruct/blocks/logic/CastingBasinLogic.java index 80d817d..1f98482 100644 --- a/mods/tinker/tconstruct/blocks/logic/CastingBasinLogic.java +++ b/mods/tinker/tconstruct/blocks/logic/CastingBasinLogic.java @@ -194,7 +194,7 @@ public class CastingBasinLogic extends InventoryLogic implements ILiquidTank, IT @Override public LiquidStack drain (int maxDrain, boolean doDrain) { - if (liquid == null || liquid.itemID <= 0) return null; + if (liquid == null || liquid.itemID <= 0 || castingDelay > 0) return null; if (liquid.amount <= 0) return null; int used = maxDrain; diff --git a/mods/tinker/tconstruct/blocks/logic/CastingTableLogic.java b/mods/tinker/tconstruct/blocks/logic/CastingTableLogic.java index fd44ec3..b1daa47 100644 --- a/mods/tinker/tconstruct/blocks/logic/CastingTableLogic.java +++ b/mods/tinker/tconstruct/blocks/logic/CastingTableLogic.java @@ -194,7 +194,7 @@ public class CastingTableLogic extends InventoryLogic implements ILiquidTank, IT @Override public LiquidStack drain (int maxDrain, boolean doDrain) { - if (liquid == null || liquid.itemID <= 0) return null; + if (liquid == null || liquid.itemID <= 0 || castingDelay > 0) return null; if (liquid.amount <= 0) return null; int used = maxDrain; diff --git a/mods/tinker/tconstruct/blocks/logic/GlowstoneAggregator.java b/mods/tinker/tconstruct/blocks/logic/GlowstoneAggregator.java index 75a0cd6..a852ef0 100644 --- a/mods/tinker/tconstruct/blocks/logic/GlowstoneAggregator.java +++ b/mods/tinker/tconstruct/blocks/logic/GlowstoneAggregator.java @@ -12,7 +12,7 @@ public class GlowstoneAggregator extends AggregatorLogic { short currentTime; short maxTime = 20 * 60 * 5; - int currentLightLevel; + public int currentLightLevel; public GlowstoneAggregator() { diff --git a/mods/tinker/tconstruct/blocks/logic/SmelteryLogic.java b/mods/tinker/tconstruct/blocks/logic/SmelteryLogic.java index 136415a..531d007 100644 --- a/mods/tinker/tconstruct/blocks/logic/SmelteryLogic.java +++ b/mods/tinker/tconstruct/blocks/logic/SmelteryLogic.java @@ -41,6 +41,7 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci int internalTemp; public int useTime; public int fuelGague; + public int fuelAmount; boolean inUse; ArrayList lavaTanks; @@ -374,13 +375,14 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci } } - void updateFuelGague () + public void updateFuelDisplay () { if (activeLavaTank == null || useTime > 0) return; if (!worldObj.blockExists(activeLavaTank.x, activeLavaTank.y, activeLavaTank.z)) { + fuelAmount = 0; fuelGague = 0; return; } @@ -388,6 +390,45 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci TileEntity tankContainer = worldObj.getBlockTileEntity(activeLavaTank.x, activeLavaTank.y, activeLavaTank.z); if (tankContainer == null) { + fuelAmount = 0; + fuelGague = 0; + return; + } + if (tankContainer instanceof ITankContainer) + { + needsUpdate = true; + LiquidStack liquid = ((ITankContainer) tankContainer).drain(ForgeDirection.DOWN, 150, false); + if (liquid != null && liquid.itemID == Block.lavaStill.blockID) + { + ILiquidTank tank = ((ITankContainer) tankContainer).getTank(ForgeDirection.DOWN, liquid); + int capacity = tank.getCapacity(); + fuelAmount = liquid.amount; + fuelGague = liquid.amount * 52 / capacity; + } + else + { + fuelAmount = 0; + fuelGague = 0; + } + } + } + + void updateFuelGague () + { + if (activeLavaTank == null || useTime > 0) + return; + + if (!worldObj.blockExists(activeLavaTank.x, activeLavaTank.y, activeLavaTank.z)) + { + fuelAmount = 0; + fuelGague = 0; + return; + } + + TileEntity tankContainer = worldObj.getBlockTileEntity(activeLavaTank.x, activeLavaTank.y, activeLavaTank.z); + if (tankContainer == null) + { + fuelAmount = 0; fuelGague = 0; return; } @@ -404,9 +445,15 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci liquid = tank.getLiquid(); int capacity = tank.getCapacity(); if (liquid != null) + { + fuelAmount = liquid.amount; fuelGague = liquid.amount * 52 / capacity; + } else + { + fuelAmount = 0; fuelGague = 0; + } } else { @@ -431,9 +478,15 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci liquid = newTank.getLiquid(); int capacity = newTank.getCapacity(); if (liquid != null) + { + fuelAmount = liquid.amount; fuelGague = liquid.amount * 52 / capacity; + } else + { + fuelAmount = 0; fuelGague = 0; + } } } iter++; @@ -746,6 +799,11 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci return maxLiquid; } + public int getTotalLiquid () + { + return currentLiquid; + } + public LiquidStack drain (int maxDrain, boolean doDrain) { if (moltenMetal.size() == 0) diff --git a/mods/tinker/tconstruct/client/BattleaxeRenderer.java b/mods/tinker/tconstruct/client/BattleaxeRenderer.java deleted file mode 100644 index 2c87bcd..0000000 --- a/mods/tinker/tconstruct/client/BattleaxeRenderer.java +++ /dev/null @@ -1,27 +0,0 @@ -package mods.tinker.tconstruct.client; - -import net.minecraft.item.ItemStack; -import net.minecraftforge.client.IItemRenderer; - -public class BattleaxeRenderer implements IItemRenderer -{ - - @Override - public boolean handleRenderType (ItemStack item, ItemRenderType type) - { - return false; - } - - @Override - public boolean shouldUseRenderHelper (ItemRenderType type, ItemStack item, ItemRendererHelper helper) - { - return true; - } - - @Override - public void renderItem (ItemRenderType type, ItemStack item, Object... data) - { - - } - -} diff --git a/mods/tinker/tconstruct/client/TClientEvents.java b/mods/tinker/tconstruct/client/TClientEvents.java index e6d91b3..ec2e845 100644 --- a/mods/tinker/tconstruct/client/TClientEvents.java +++ b/mods/tinker/tconstruct/client/TClientEvents.java @@ -3,21 +3,19 @@ package mods.tinker.tconstruct.client; import mods.tinker.tconstruct.TConstruct; import mods.tinker.tconstruct.client.armor.WingModel; import mods.tinker.tconstruct.common.TContent; -import mods.tinker.tconstruct.skill.Skill; import mods.tinker.tconstruct.util.player.TPlayerStats; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.model.ModelBiped; import net.minecraft.client.renderer.Tessellator; import net.minecraft.entity.EntityLiving; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.TextureStitchEvent; import net.minecraftforge.client.event.sound.SoundLoadEvent; import net.minecraftforge.event.ForgeSubscribe; import net.minecraftforge.liquids.LiquidStack; - -import org.lwjgl.opengl.GL11; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -74,13 +72,19 @@ public class TClientEvents @ForgeSubscribe public void renderHealthbar (RenderGameOverlayEvent.Post event) { - ScaledResolution scaledresolution = new ScaledResolution(this.mc.gameSettings, this.mc.displayWidth, this.mc.displayHeight); int scaledWidth = scaledresolution.getScaledWidth(); int scaledHeight = scaledresolution.getScaledHeight(); int xBasePos = scaledWidth / 2 - 91; int yBasePos = scaledHeight - 39; TPlayerStats stats = TConstruct.playerTracker.getPlayerStats(mc.thePlayer.username); + + PotionEffect potion = mc.thePlayer.getActivePotionEffect(Potion.wither); + if (potion != null) + return; + potion = mc.thePlayer.getActivePotionEffect(Potion.poison); + if (potion != null) + return; if (event.type == RenderGameOverlayEvent.ElementType.HEALTH) { diff --git a/mods/tinker/tconstruct/client/TProxyClient.java b/mods/tinker/tconstruct/client/TProxyClient.java index a5421c5..7f414c0 100644 --- a/mods/tinker/tconstruct/client/TProxyClient.java +++ b/mods/tinker/tconstruct/client/TProxyClient.java @@ -238,20 +238,20 @@ public class TProxyClient extends TProxyCommon //Special Renderers ClientRegistry.bindTileEntitySpecialRenderer(CastingTableLogic.class, new CastingTableSpecialRenderer()); - ClientRegistry.bindTileEntitySpecialRenderer(GolemCoreLogic.class, new GolemCoreSpecialRender()); + //ClientRegistry.bindTileEntitySpecialRenderer(GolemCoreLogic.class, new GolemCoreSpecialRender()); ClientRegistry.bindTileEntitySpecialRenderer(CastingBasinLogic.class, new CastingBasinSpecialRender()); //Entities RenderingRegistry.registerEntityRenderingHandler(FancyEntityItem.class, new FancyItemRender()); RenderingRegistry.registerEntityRenderingHandler(BlueSlime.class, new SlimeRender(new ModelSlime(16), new ModelSlime(0), 0.25F)); RenderingRegistry.registerEntityRenderingHandler(SlimeClone.class, new SlimeCloneRender(new CloneHeadModel(0), new CloneHeadModel(1f), 0.25F)); - RenderingRegistry.registerEntityRenderingHandler(GolemBase.class, new GolemRender(0)); + //RenderingRegistry.registerEntityRenderingHandler(GolemBase.class, new GolemRender(0)); RenderingRegistry.registerEntityRenderingHandler(CartEntity.class, new CartRender()); RenderingRegistry.registerEntityRenderingHandler(DaggerEntity.class, new DaggerRender()); - RenderingRegistry.registerEntityRenderingHandler(Skyla.class, new SkylaRender()); - RenderingRegistry.registerEntityRenderingHandler(Crystal.class, new CrystalRender()); - RenderingRegistry.registerEntityRenderingHandler(Automaton.class, new RenderBiped(new ModelBiped(), 0)); + // RenderingRegistry.registerEntityRenderingHandler(Skyla.class, new SkylaRender()); + RenderingRegistry.registerEntityRenderingHandler(Automaton.class, new CrystalGuardianRender()); + //RenderingRegistry.registerEntityRenderingHandler(Automaton.class, new RenderBiped(new ModelBiped(), 0)); RenderingRegistry.registerEntityRenderingHandler(LaunchedPotion.class, new LaunchedItemRender(Item.potion, 16384)); //RenderingRegistry.registerEntityRenderingHandler(net.minecraft.entity.player.EntityPlayer.class, new PlayerArmorRender()); // <-- Works, woo! diff --git a/mods/tinker/tconstruct/client/entity/CrystalGuardianRender.java b/mods/tinker/tconstruct/client/entity/CrystalGuardianRender.java new file mode 100644 index 0000000..c56b436 --- /dev/null +++ b/mods/tinker/tconstruct/client/entity/CrystalGuardianRender.java @@ -0,0 +1,188 @@ +package mods.tinker.tconstruct.client.entity; + +import static net.minecraftforge.client.IItemRenderer.ItemRenderType.EQUIPPED; +import static net.minecraftforge.client.IItemRenderer.ItemRendererHelper.BLOCK_3D; +import mods.tinker.tconstruct.entity.Automaton; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.entity.RenderLiving; +import net.minecraft.client.renderer.tileentity.TileEntitySkullRenderer; +import net.minecraft.entity.EntityLiving; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.src.CrystalGuardianModel; +import net.minecraftforge.client.IItemRenderer; +import net.minecraftforge.client.MinecraftForgeClient; + +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class CrystalGuardianRender extends RenderLiving +{ + CrystalGuardianModel model; + public CrystalGuardianRender() + { + super(new CrystalGuardianModel(), 0.5F); + this.model = (CrystalGuardianModel)this.mainModel; + } + + @Override + protected void renderEquippedItems(EntityLiving par1EntityLiving, float par2) + { + float f1 = 1.0F; + GL11.glColor3f(f1, f1, f1); + super.renderEquippedItems(par1EntityLiving, par2); + ItemStack itemstack = par1EntityLiving.getHeldItem(); + ItemStack itemstack1 = par1EntityLiving.getCurrentArmor(3); + float f2; + + if (itemstack1 != null) + { + GL11.glPushMatrix(); + this.model.head.postRender(0.0625F); + + IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(itemstack1, EQUIPPED); + boolean is3D = (customRenderer != null && customRenderer.shouldUseRenderHelper(EQUIPPED, itemstack1, BLOCK_3D)); + + if (itemstack1.getItem() instanceof ItemBlock) + { + if (is3D || RenderBlocks.renderItemIn3d(Block.blocksList[itemstack1.itemID].getRenderType())) + { + f2 = 0.625F; + GL11.glTranslatef(0.0F, -0.25F, 0.0F); + GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); + GL11.glScalef(f2, -f2, -f2); + } + + this.renderManager.itemRenderer.renderItem(par1EntityLiving, itemstack1, 0); + } + else if (itemstack1.getItem().itemID == Item.skull.itemID) + { + f2 = 1.0625F; + GL11.glScalef(f2, -f2, -f2); + String s = ""; + + if (itemstack1.hasTagCompound() && itemstack1.getTagCompound().hasKey("SkullOwner")) + { + s = itemstack1.getTagCompound().getString("SkullOwner"); + } + + TileEntitySkullRenderer.skullRenderer.func_82393_a(-0.5F, 0.0F, -0.5F, 1, 180.0F, itemstack1.getItemDamage(), s); + } + + GL11.glPopMatrix(); + } + + if (itemstack != null) + { + GL11.glPushMatrix(); + + if (this.mainModel.isChild) + { + f2 = 0.5F; + GL11.glTranslatef(0.0F, 0.625F, 0.0F); + GL11.glRotatef(-20.0F, -1.0F, 0.0F, 0.0F); + GL11.glScalef(f2, f2, f2); + } + + this.model.rightarm.postRender(0.0625F); + GL11.glTranslatef(-0.125F, 1F, 0F); + + IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(itemstack, EQUIPPED); + boolean is3D = (customRenderer != null && customRenderer.shouldUseRenderHelper(EQUIPPED, itemstack, BLOCK_3D)); + + if (itemstack.getItem() instanceof ItemBlock && (is3D || RenderBlocks.renderItemIn3d(Block.blocksList[itemstack.itemID].getRenderType()))) + { + f2 = 0.5F; + GL11.glTranslatef(0.0F, 0.1875F, -0.3125F); + f2 *= 0.75F; + GL11.glRotatef(20.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); + GL11.glScalef(-f2, -f2, f2); + } + else if (itemstack.itemID == Item.bow.itemID) + { + f2 = 0.625F; + GL11.glTranslatef(0.0F, 0.125F, 0.3125F); + GL11.glRotatef(-20.0F, 0.0F, 1.0F, 0.0F); + GL11.glScalef(f2, -f2, f2); + GL11.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); + } + else if (Item.itemsList[itemstack.itemID].isFull3D()) + { + f2 = 0.625F; + + if (Item.itemsList[itemstack.itemID].shouldRotateAroundWhenRendering()) + { + GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); + GL11.glTranslatef(0.0F, -0.125F, 0.0F); + } + + this.func_82422_c(); + GL11.glScalef(f2, -f2, f2); + GL11.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); + } + else + { + f2 = 0.375F; + GL11.glTranslatef(0.25F, 0.1875F, -0.1875F); + GL11.glScalef(f2, f2, f2); + GL11.glRotatef(60.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(-90.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(20.0F, 0.0F, 0.0F, 1.0F); + } + + float f6; + float f11; + int j; + float f12; + + if (itemstack.getItem().requiresMultipleRenderPasses()) + { + for (j = 0; j < itemstack.getItem().getRenderPasses(itemstack.getItemDamage()); j++) + { + int k = itemstack.getItem().getColorFromItemStack(itemstack, j); + f12 = (float)(k >> 16 & 255) / 255.0F; + f11 = (float)(k >> 8 & 255) / 255.0F; + f6 = (float)(k & 255) / 255.0F; + GL11.glColor4f(f12, f11, f6, 1.0F); + this.renderManager.itemRenderer.renderItem(par1EntityLiving, itemstack, j); + } + } + else + { + j = itemstack.getItem().getColorFromItemStack(itemstack, 0); + f6 = (float)(j >> 16 & 255) / 255.0F; + f12 = (float)(j >> 8 & 255) / 255.0F; + f11 = (float)(j & 255) / 255.0F; + GL11.glColor4f(f6, f12, f11, 1.0F); + this.renderManager.itemRenderer.renderItem(par1EntityLiving, itemstack, 0); + } + + /*this.renderManager.itemRenderer.renderItem(par1EntityLiving, itemstack, 0); + + if (itemstack.getItem().requiresMultipleRenderPasses()) + { + for (int x = 1; x < itemstack.getItem().getRenderPasses(itemstack.getItemDamage()); x++) + { + this.renderManager.itemRenderer.renderItem(par1EntityLiving, itemstack, x); + } + }*/ + + GL11.glPopMatrix(); + } + } + + protected void func_82422_c() + { + GL11.glTranslatef(0.0F, 0.1875F, 0.0F); + } +} diff --git a/mods/tinker/tconstruct/client/entity/CrystalRender.java b/mods/tinker/tconstruct/client/entity/CrystalRender.java deleted file mode 100644 index ad01db3..0000000 --- a/mods/tinker/tconstruct/client/entity/CrystalRender.java +++ /dev/null @@ -1,164 +0,0 @@ -package mods.tinker.tconstruct.client.entity; - -import mods.tinker.tconstruct.entity.Crystal; -import net.minecraft.client.model.ModelBase; -import net.minecraft.client.renderer.entity.RenderLiving; -import net.minecraft.entity.EntityLiving; -import net.minecraft.util.MathHelper; - -import org.lwjgl.opengl.GL11; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -public class CrystalRender extends RenderLiving -{ - /** The creeper model. */ - private ModelBase creeperModel = new SkylaModel(); - - public CrystalRender() - { - super(new CrystalModel(), 0.5F); - } - - /** - * Updates creeper scale in prerender callback - */ - protected void updateCreeperScale(Crystal par1EntityCreeper, float par2) - { - float var4 = par1EntityCreeper.getCreeperFlashIntensity(par2); - float var5 = 1.0F + MathHelper.sin(var4 * 100.0F) * var4 * 0.01F; - - if (var4 < 0.0F) - { - var4 = 0.0F; - } - - if (var4 > 1.0F) - { - var4 = 1.0F; - } - - var4 *= var4; - var4 *= var4; - float var6 = (1.0F + var4 * 0.4F) * var5; - float var7 = (1.0F + var4 * 0.1F) / var5; - GL11.glScalef(var6, var7, var6); - } - - /** - * Updates color multiplier based on creeper state called by getColorMultiplier - */ - protected int updateCreeperColorMultiplier(Crystal par1EntityCreeper, float par2, float par3) - { - float var5 = par1EntityCreeper.getCreeperFlashIntensity(par3); - - if ((int)(var5 * 10.0F) % 2 == 0) - { - return 0; - } - else - { - int var6 = (int)(var5 * 0.2F * 255.0F); - - if (var6 < 0) - { - var6 = 0; - } - - if (var6 > 255) - { - var6 = 255; - } - - short var7 = 255; - short var8 = 255; - short var9 = 255; - return var6 << 24 | var7 << 16 | var8 << 8 | var9; - } - } - - /** - * A method used to render a creeper's powered form as a pass model. - */ - protected int renderCreeperPassModel(Crystal par1EntityCreeper, int par2, float par3) - { - if (par1EntityCreeper.getPowered()) - { - if (par1EntityCreeper.isInvisible()) - { - GL11.glDepthMask(false); - } - else - { - GL11.glDepthMask(true); - } - - if (par2 == 1) - { - float var4 = (float)par1EntityCreeper.ticksExisted + par3; - this.loadTexture("/armor/power.png"); - GL11.glMatrixMode(GL11.GL_TEXTURE); - GL11.glLoadIdentity(); - float var5 = var4 * 0.01F; - float var6 = var4 * 0.01F; - GL11.glTranslatef(var5, var6, 0.0F); - this.setRenderPassModel(this.creeperModel); - GL11.glMatrixMode(GL11.GL_MODELVIEW); - GL11.glEnable(GL11.GL_BLEND); - float var7 = 0.5F; - GL11.glColor4f(var7, var7, var7, 1.0F); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); - return 1; - } - - if (par2 == 2) - { - GL11.glMatrixMode(GL11.GL_TEXTURE); - GL11.glLoadIdentity(); - GL11.glMatrixMode(GL11.GL_MODELVIEW); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_BLEND); - } - } - - return -1; - } - - protected int func_77061_b(Crystal par1EntityCreeper, int par2, float par3) - { - return -1; - } - - /** - * Allows the render to do any OpenGL state modifications necessary before the model is rendered. Args: - * entityLiving, partialTickTime - */ - protected void preRenderCallback(EntityLiving par1EntityLiving, float par2) - { - this.updateCreeperScale((Crystal)par1EntityLiving, par2); - } - - /** - * Returns an ARGB int color back. Args: entityLiving, lightBrightness, partialTickTime - */ - protected int getColorMultiplier(EntityLiving par1EntityLiving, float par2, float par3) - { - return this.updateCreeperColorMultiplier((Crystal)par1EntityLiving, par2, par3); - } - - /** - * Queries whether should render the specified pass or not. - */ - protected int shouldRenderPass(EntityLiving par1EntityLiving, int par2, float par3) - { - return this.renderCreeperPassModel((Crystal)par1EntityLiving, par2, par3); - } - - protected int inheritRenderPass(EntityLiving par1EntityLiving, int par2, float par3) - { - return this.func_77061_b((Crystal)par1EntityLiving, par2, par3); - } -} diff --git a/mods/tinker/tconstruct/client/entity/SlimeCloneRender.java b/mods/tinker/tconstruct/client/entity/SlimeCloneRender.java index 01827fd..1f115e2 100644 --- a/mods/tinker/tconstruct/client/entity/SlimeCloneRender.java +++ b/mods/tinker/tconstruct/client/entity/SlimeCloneRender.java @@ -55,7 +55,7 @@ public class SlimeCloneRender extends RenderLiving */ protected void scaleSlime(SlimeClone slimeClone, float par2) { - float f1 = 2; + float f1 = slimeClone.getSlimeSize(); float f2 = (slimeClone.sizeHeight + (slimeClone.sizeFactor - slimeClone.sizeHeight) * par2) / (f1 * 0.5F + 1.0F); float f3 = 1.0F / (f2 + 1.0F); GL11.glScalef(f3 * f1, 1.0F / f3 * f1, f3 * f1); diff --git a/mods/tinker/tconstruct/client/gui/SmelteryGui.java b/mods/tinker/tconstruct/client/gui/SmelteryGui.java index e3dbc8a..940b1bd 100644 --- a/mods/tinker/tconstruct/client/gui/SmelteryGui.java +++ b/mods/tinker/tconstruct/client/gui/SmelteryGui.java @@ -1,35 +1,34 @@ package mods.tinker.tconstruct.client.gui; -import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; import mods.tinker.tconstruct.blocks.logic.SmelteryLogic; import mods.tinker.tconstruct.inventory.ActiveContainer; import mods.tinker.tconstruct.inventory.SmelteryContainer; import net.minecraft.block.Block; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.Tessellator; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Slot; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.network.packet.Packet250CustomPayload; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.nbt.NBTTagString; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.Icon; -import net.minecraft.util.MathHelper; import net.minecraft.util.StatCollector; import net.minecraft.world.World; +import net.minecraftforge.liquids.LiquidDictionary; import net.minecraftforge.liquids.LiquidStack; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; -import cpw.mods.fml.common.network.PacketDispatcher; - public class SmelteryGui extends NewContainerGui { public SmelteryLogic logic; @@ -46,6 +45,7 @@ public class SmelteryGui extends NewContainerGui logic = smeltery; username = inventoryplayer.player.username; xSize = 248; + smeltery.updateFuelDisplay(); } public void drawScreen (int mouseX, int mouseY, float par3) @@ -104,13 +104,62 @@ public class SmelteryGui extends NewContainerGui } } - protected void drawGuiContainerForegroundLayer (int par1, int par2) + protected void drawGuiContainerForegroundLayer (int mouseX, int mouseY) { fontRenderer.drawString(StatCollector.translateToLocal("crafters.Smeltery"), 86, 5, 0x404040); fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 90, (ySize - 96) + 2, 0x404040); + + int base = 0; + int cornerX = (width - xSize) / 2 + 36; + int cornerY = (height - ySize) / 2; + for (LiquidStack liquid : logic.moltenMetal) + { + int basePos = 54; + int initialLiquidSize = 0; + int liquidSize = 0;//liquid.amount * 52 / liquidLayers; + if (logic.getCapacity() > 0) + { + int total = logic.getTotalLiquid(); + int liquidLayers = (total / 20000 + 1) * 20000; + liquidSize = liquid.amount * 52 / liquidLayers; + base += liquidSize; + } + + int leftX = cornerX + basePos; + int topY = (cornerY + 68) - base; + int sizeX = 52; + int sizeY = liquidSize; + if (mouseX >= leftX && mouseX <= leftX + sizeX && mouseY >= topY && mouseY < topY + sizeY) + { + drawLiquidStackTooltip(liquid, mouseX - cornerX + 36, mouseY - cornerY); + } + } + + if (logic.fuelGague > 0) + { + int leftX = cornerX + 117; + int topY = (cornerY + 68) - logic.getScaledFuelGague(52); + int sizeX = 12; + int sizeY = logic.getScaledFuelGague(52); + if (mouseX >= leftX && mouseX <= leftX + sizeX && mouseY >= topY && mouseY < topY + sizeY) + { + drawLiquidStackTooltip(new LiquidStack(Block.lavaStill.blockID, logic.fuelAmount, 0), mouseX - cornerX + 36, mouseY - cornerY); + } + /*this.mc.renderEngine.bindTexture("/terrain.png"); + Icon lavaIcon = Block.lavaStill.getIcon(0, 0); + int fuel = logic.getScaledFuelGague(52); + int count = 0; + while (fuel > 0) + { + int size = fuel >= 16 ? 16 : fuel; + fuel -= size; + drawTexturedModelRectFromIcon(cornerX + 117, (cornerY + 68) - size - 16 * count, lavaIcon, 12, size); + count++; + }*/ + } } - protected void drawGuiContainerBackgroundLayer (float f, int i, int j) + protected void drawGuiContainerBackgroundLayer (float f, int mouseX, int mouseY) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); mc.renderEngine.bindTexture("/mods/tinker/textures/gui/smeltery.png"); @@ -153,13 +202,15 @@ public class SmelteryGui extends NewContainerGui renderIndex = liquidItem.getIconFromDamage(liquid.itemMeta); } + int basePos = 54; if (logic.getCapacity() > 0) { - int liquidSize = liquid.amount * 52 / logic.getCapacity(); + int total = logic.getTotalLiquid(); + int liquidLayers = (total / 20000 + 1) * 20000; + int liquidSize = liquid.amount * 52 / liquidLayers; while (liquidSize > 0) { int size = liquidSize >= 16 ? 16 : liquidSize; - int basePos = 54; drawTexturedModelRectFromIcon(cornerX + basePos, (cornerY + 68) - size - base, renderIndex, 16, size); drawTexturedModelRectFromIcon(cornerX + basePos + 16, (cornerY + 68) - size - base, renderIndex, 16, size); drawTexturedModelRectFromIcon(cornerX + basePos + 32, (cornerY + 68) - size - base, renderIndex, 16, size); @@ -168,6 +219,15 @@ public class SmelteryGui extends NewContainerGui base += size; } } + + /*int leftX = cornerX + basePos; + int topY = (cornerY + 68) - base; + int sizeX = 52; + int sizeY = base; + if (mouseX >= leftX && mouseX <= leftX + sizeX && mouseY >= topY && mouseY <= topY + sizeY) + { + drawLiquidStackTooltip(liquid, mouseX, mouseY); + }*/ } //Liquid gague @@ -212,10 +272,121 @@ public class SmelteryGui extends NewContainerGui drawTexturedModalRect(cornerX - 38 + (iter % 3 * 22), cornerY + 8 + (iter / 3 * 18) + 16 - size, 98, 15 + 16 - size, 5, size); } } + } + + protected void drawLiquidStackTooltip (LiquidStack par1ItemStack, int par2, int par3) + { + this.zLevel = 100; + List list = getLiquidTooltip(par1ItemStack, this.mc.gameSettings.advancedItemTooltips); - //fontRenderer.drawString("slotPos: "+slotPos, 140, 2, 0xFFFFFF); - /*fontRenderer.drawString("Scrolling: "+isScrolling, 140, 12, 0xFFFFFF); - fontRenderer.drawString("Scroll: "+currentScroll, 140, 22, 0xFFFFFF);*/ + for (int k = 0; k < list.size(); ++k) + { + list.set(k, EnumChatFormatting.GRAY + (String) list.get(k)); + } + + this.drawToolTip(list, par2, par3); + this.zLevel = 0; + } + + public List getLiquidTooltip(LiquidStack liquid, boolean par2) + { + ArrayList list = new ArrayList(); + if (liquid.itemID == Block.lavaStill.blockID) + { + list.add("\u00A7fFuel"); + int mB = liquid.amount; + if (mB > 0) + list.add("mB: "+mB); + } + else + { + list.add("\u00A7f"+LiquidDictionary.findLiquidName(liquid)); + int ingots = liquid.amount / 144; + if (ingots > 0) + list.add("Ingots: "+ingots); + int mB = liquid.amount % 144; + if (mB > 0) + list.add("mB: "+mB); + } + return list; + } + + protected void drawToolTip (List par1List, int par2, int par3) + { + if (!par1List.isEmpty()) + { + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + int k = 0; + Iterator iterator = par1List.iterator(); + + while (iterator.hasNext()) + { + String s = (String) iterator.next(); + int l = this.fontRenderer.getStringWidth(s); + + if (l > k) + { + k = l; + } + } + + int i1 = par2 + 12; + int j1 = par3 - 12; + int k1 = 8; + + if (par1List.size() > 1) + { + k1 += 2 + (par1List.size() - 1) * 10; + } + + if (i1 + k > this.width) + { + i1 -= 28 + k; + } + + if (j1 + k1 + 6 > this.height) + { + j1 = this.height - k1 - 6; + } + + this.zLevel = 300.0F; + itemRenderer.zLevel = 300.0F; + int l1 = -267386864; + this.drawGradientRect(i1 - 3, j1 - 4, i1 + k + 3, j1 - 3, l1, l1); + this.drawGradientRect(i1 - 3, j1 + k1 + 3, i1 + k + 3, j1 + k1 + 4, l1, l1); + this.drawGradientRect(i1 - 3, j1 - 3, i1 + k + 3, j1 + k1 + 3, l1, l1); + this.drawGradientRect(i1 - 4, j1 - 3, i1 - 3, j1 + k1 + 3, l1, l1); + this.drawGradientRect(i1 + k + 3, j1 - 3, i1 + k + 4, j1 + k1 + 3, l1, l1); + int i2 = 1347420415; + int j2 = (i2 & 16711422) >> 1 | i2 & -16777216; + this.drawGradientRect(i1 - 3, j1 - 3 + 1, i1 - 3 + 1, j1 + k1 + 3 - 1, i2, j2); + this.drawGradientRect(i1 + k + 2, j1 - 3 + 1, i1 + k + 3, j1 + k1 + 3 - 1, i2, j2); + this.drawGradientRect(i1 - 3, j1 - 3, i1 + k + 3, j1 - 3 + 1, i2, i2); + this.drawGradientRect(i1 - 3, j1 + k1 + 2, i1 + k + 3, j1 + k1 + 3, j2, j2); + + for (int k2 = 0; k2 < par1List.size(); ++k2) + { + String s1 = (String) par1List.get(k2); + this.fontRenderer.drawStringWithShadow(s1, i1, j1, -1); + + if (k2 == 0) + { + j1 += 2; + } + + j1 += 10; + } + + this.zLevel = 0.0F; + itemRenderer.zLevel = 0.0F; + /*GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + RenderHelper.enableStandardItemLighting(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL);*/ + } } public void drawLiquidRect(int par1, int par2, Icon par3Icon, int par4, int par5) diff --git a/mods/tinker/tconstruct/client/gui/StencilTableGui.java b/mods/tinker/tconstruct/client/gui/StencilTableGui.java index 957dc10..88cd7e9 100644 --- a/mods/tinker/tconstruct/client/gui/StencilTableGui.java +++ b/mods/tinker/tconstruct/client/gui/StencilTableGui.java @@ -104,19 +104,7 @@ public class StencilTableGui extends GuiContainer } else if (meta == 1) { - if (button.id == 0) - { - patternIndex++; - if (patternIndex > TContent.patternOutputs.length-1) - patternIndex = 0; - } - else if (button.id == 1) - { - patternIndex--; - if (patternIndex < 0) - patternIndex = TContent.patternOutputs.length-1; - } - ItemStack stack = new ItemStack(TContent.metalPattern, 1, patternIndex); + ItemStack stack = new ItemStack(TContent.metalPattern, 1, 0); logic.setInventorySlotContents(1, stack); updateServer(stack); } diff --git a/mods/tinker/tconstruct/common/TContent.java b/mods/tinker/tconstruct/common/TContent.java index 9bf1674..fdd0b12 100644 --- a/mods/tinker/tconstruct/common/TContent.java +++ b/mods/tinker/tconstruct/common/TContent.java @@ -24,9 +24,11 @@ import net.minecraft.block.material.Material; import net.minecraft.block.material.MaterialLiquid; import net.minecraft.entity.EnumCreatureType; import net.minecraft.item.Item; +import net.minecraft.item.ItemAppleGold; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.FurnaceRecipes; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.potion.Potion; import net.minecraft.util.WeightedRandomChestContent; import net.minecraft.world.biome.BiomeGenBase; import net.minecraftforge.common.BiomeDictionary; @@ -186,6 +188,7 @@ public class TContent implements IFuelHandler public static Item knapsack; public static Item heartCanister; + public static Item goldHead; //Chest hooks public static ChestGenHooks tinkerHouseChest; @@ -206,12 +209,12 @@ public class TContent implements IFuelHandler EntityRegistry.registerModEntity(FancyEntityItem.class, "Fancy Item", 0, TConstruct.instance, 32, 5, true); EntityRegistry.registerModEntity(DaggerEntity.class, "Dagger", 1, TConstruct.instance, 32, 5, true); //EntityRegistry.registerModEntity(Crystal.class, "Crystal", 2, TConstruct.instance, 32, 5, true); - //EntityRegistry.registerModEntity(SlimeClone.class, "SlimeClone", 2, TConstruct.instance, 32, 5, true); //EntityRegistry.registerModEntity(LaunchedPotion.class, "Launched Potion", 1, TConstruct.instance, 32, 3, true); //EntityRegistry.registerModEntity(CartEntity.class, "Small Wagon", 1, TConstruct.instance, 32, 5, true); //EntityRegistry.registerModEntity(Skyla.class, "Skyla", 10, TConstruct.instance, 32, 5, true); - EntityRegistry.registerModEntity(Automaton.class, "Automaton", 11, TConstruct.instance, 64, 5, true); + EntityRegistry.registerModEntity(SlimeClone.class, "SlimeClone", 10, TConstruct.instance, 32, 3, true); + EntityRegistry.registerModEntity(Automaton.class, "Automaton", 11, TConstruct.instance, 64, 3, true); EntityRegistry.registerModEntity(BlueSlime.class, "EdibleSlime", 12, TConstruct.instance, 64, 5, true); //EntityRegistry.registerModEntity(MetalSlime.class, "MetalSlime", 13, TConstruct.instance, 64, 5, true); @@ -507,6 +510,8 @@ public class TContent implements IFuelHandler public static Item heavyPants; public static Item heavyBoots;*/ + goldHead = new GoldenHead(PHConstruct.goldHead, 4, 1.2F, false).setAlwaysEdible().setPotionEffect(Potion.regeneration.id, 10, 0, 1.0F).setUnlocalizedName("goldenhead"); + String[] materialStrings = { "paperStack", "greenSlimeCrystal", "searedBrick", "ingotCobalt", "ingotArdite", "ingotManyullyn", "mossBall", "lavaCrystal", "necroticBone", "ingotCopper", "ingotTin", "ingotAluminum", "rawAluminum", "ingotBronze", "ingotAluminumBrass", "ingotAlumite", "ingotSteel", "blueSlimeCrystal", "ingotObsidian", "nuggetIron", "nuggetCopper", "nuggetTin", "nuggetAluminum", "nuggetSilver", "nuggetAluminumBrass", "silkyCloth", "silkyJewel" }; @@ -778,7 +783,7 @@ public class TContent implements IFuelHandler tableCasting.addCastingRecipe(new ItemStack(buckets, 1, 5), new LiquidStack(liquidMetalStill.blockID, TConstruct.ingotLiquidValue * 9, 5), bucket, true, 10); //cobalt tableCasting.addCastingRecipe(new ItemStack(buckets, 1, 6), new LiquidStack(liquidMetalStill.blockID, TConstruct.ingotLiquidValue * 9, 6), bucket, true, 10); //ardite tableCasting.addCastingRecipe(new ItemStack(buckets, 1, 7), new LiquidStack(liquidMetalStill.blockID, TConstruct.ingotLiquidValue * 9, 7), bucket, true, 10); //bronze - tableCasting.addCastingRecipe(new ItemStack(buckets, 1, 8), new LiquidStack(liquidMetalStill.blockID, TConstruct.ingotLiquidValue * 9, 8), bucket, true, 10); //albrass + tableCasting.addCastingRecipe(new ItemStack(buckets, 1, 8), new LiquidStack(liquidMetalStill.blockID, TConstruct.ingotLiquidValue * 9, 8), bucket, true, 10); //alubrass tableCasting.addCastingRecipe(new ItemStack(buckets, 1, 9), new LiquidStack(liquidMetalStill.blockID, TConstruct.ingotLiquidValue * 9, 9), bucket, true, 10); //manyullyn tableCasting.addCastingRecipe(new ItemStack(buckets, 1, 10), new LiquidStack(liquidMetalStill.blockID, TConstruct.ingotLiquidValue * 9, 10), bucket, true, 10); //alumite tableCasting.addCastingRecipe(new ItemStack(buckets, 1, 11), new LiquidStack(liquidMetalStill.blockID, TConstruct.ingotLiquidValue * 9, 11), bucket, true, 10);// obsidian @@ -792,6 +797,12 @@ public class TContent implements IFuelHandler for (int iter = 0; iter < patternOutputs.length; iter++) { ItemStack cast = new ItemStack(metalPattern, 1, iter + 1); + + tableCasting.addCastingRecipe(cast, new LiquidStack(liquidMetalStill.blockID, TConstruct.ingotLiquidValue, 8), new ItemStack(woodPattern, 1, iter+1), true, 50); + tableCasting.addCastingRecipe(cast, new LiquidStack(liquidMetalStill.blockID, TConstruct.ingotLiquidValue*2, 1), new ItemStack(woodPattern, 1, iter+1), true, 50); + tableCasting.addCastingRecipe(cast, new LiquidStack(liquidMetalStill.blockID, TConstruct.ingotLiquidValue, 8), new ItemStack(patternOutputs[iter], 1, Short.MAX_VALUE), false, 50); + tableCasting.addCastingRecipe(cast, new LiquidStack(liquidMetalStill.blockID, TConstruct.ingotLiquidValue*2, 1), new ItemStack(patternOutputs[iter], 1, Short.MAX_VALUE), false, 50); + for (int iterTwo = 0; iterTwo < liquids.length; iterTwo++) { ItemStack metalCast = new ItemStack(patternOutputs[iter], 1, liquidDamage[iterTwo]); @@ -799,6 +810,12 @@ public class TContent implements IFuelHandler liquids[iterTwo].itemMeta), cast, 50); } } + + ItemStack fullguardCast = new ItemStack(metalPattern, 1, 22); + tableCasting.addCastingRecipe(fullguardCast, new LiquidStack(liquidMetalStill.blockID, TConstruct.ingotLiquidValue, 8), new ItemStack(woodPattern, 1, 22), true, 50); + tableCasting.addCastingRecipe(fullguardCast, new LiquidStack(liquidMetalStill.blockID, TConstruct.ingotLiquidValue*2, 1), new ItemStack(woodPattern, 1, 22), true, 50); + tableCasting.addCastingRecipe(fullguardCast, new LiquidStack(liquidMetalStill.blockID, TConstruct.ingotLiquidValue, 8), new ItemStack(fullGuard, 1, Short.MAX_VALUE), false, 50); + tableCasting.addCastingRecipe(fullguardCast, new LiquidStack(liquidMetalStill.blockID, TConstruct.ingotLiquidValue*2, 1), new ItemStack(fullGuard, 1, Short.MAX_VALUE), false, 50); LiquidCasting basinCasting = TConstructRegistry.getBasinCasting(); basinCasting.addCastingRecipe(new ItemStack(Block.blockIron), new LiquidStack(liquidMetalStill.blockID, TConstruct.ingotLiquidValue * 9, 0), null, true, 100); //Iron @@ -1068,6 +1085,24 @@ public class TContent implements IFuelHandler RecipeRemover.removeShapedRecipe(new ItemStack(Block.blockIron)); RecipeRemover.removeShapedRecipe(new ItemStack(Block.blockGold)); } + + //Ultra hardcore recipes + String[] surround = { "###", "#m#", "###" }; + if (PHConstruct.goldAppleRecipe) + { + RecipeRemover.removeShapedRecipe(new ItemStack(Item.appleGold)); + RecipeRemover.removeShapedRecipe(new ItemStack(Item.goldenCarrot)); + RecipeRemover.removeShapelessRecipe(new ItemStack(Item.speckledMelon)); + + GameRegistry.addRecipe(new ItemStack(Item.appleGold), surround, '#', new ItemStack(Item.ingotGold), 'm', new ItemStack(Item.appleRed)); + GameRegistry.addRecipe(new ItemStack(Item.goldenCarrot), surround, '#', new ItemStack(Item.ingotGold), 'm', new ItemStack(Item.carrot)); + GameRegistry.addRecipe(new ItemStack(goldHead), surround, '#', new ItemStack(Item.ingotGold), 'm', new ItemStack(Item.skull, 1, 3)); + GameRegistry.addShapelessRecipe(new ItemStack(Item.speckledMelon), new ItemStack(Block.blockGold), new ItemStack(Item.melon)); + } + else + { + GameRegistry.addRecipe(new ItemStack(goldHead), surround, '#', new ItemStack(Item.goldNugget), 'm', new ItemStack(Item.skull, 1, 3)); + } } void setupToolTabs () @@ -1163,7 +1198,7 @@ public class TContent implements IFuelHandler OreDictionary.registerOre("nuggetSilver", new ItemStack(materials, 1, 23)); OreDictionary.registerOre("nuggetAluminumBrass", new ItemStack(materials, 1, 24)); - String[] names = new String[] { "Iron", "Gold", "Copper", "Tin", "Aluminum", "Cobalt", "Ardite", "Bronze", "Brass", "Manyullyn", "Alumite", "Obsidian", "Steel" }; + String[] names = new String[] { "Iron", "Gold", "Copper", "Tin", "Aluminum", "Cobalt", "Ardite", "Bronze", "Aluminum Brass", "Manyullyn", "Alumite", "Obsidian", "Steel" }; liquidIcons = new LiquidStack[names.length]; liquidNames = new String[names.length]; for (int iter = 0; iter < names.length; iter++) diff --git a/mods/tinker/tconstruct/crystal/TheftValueTracker.java b/mods/tinker/tconstruct/crystal/TheftValueTracker.java new file mode 100644 index 0000000..5e133a6 --- /dev/null +++ b/mods/tinker/tconstruct/crystal/TheftValueTracker.java @@ -0,0 +1,22 @@ +package mods.tinker.tconstruct.crystal; + +import java.util.ArrayList; +import java.util.HashMap; + +import mods.tinker.tconstruct.library.util.ChunkCoordTuple; + +public class TheftValueTracker +{ + public static HashMap chunkMap = new HashMap(); + //public static HashMap crystallinity = new HashMap(); + public static HashMap> crystallinity = new HashMap>(); + + public static void updateCrystallinity(int posX, int posZ, int world, int value) + { + ChunkCoordTuple tuple = new ChunkCoordTuple((int)Math.floor(posX/16), (int)Math.floor(posZ/16)); + HashMap dimensionMap = crystallinity.get(world); + int level = dimensionMap.get(tuple); + level += value; + dimensionMap.put(tuple, level); + } +} diff --git a/mods/tinker/tconstruct/entity/Automaton.java b/mods/tinker/tconstruct/entity/Automaton.java index 24d894c..89a4fc4 100644 --- a/mods/tinker/tconstruct/entity/Automaton.java +++ b/mods/tinker/tconstruct/entity/Automaton.java @@ -1,46 +1,71 @@ package mods.tinker.tconstruct.entity; -import java.util.*; - import mods.tinker.tconstruct.entity.ai.*; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; import net.minecraft.world.World; public class Automaton extends GolemBase { int state; - TaskBase currentTask; - HashMap taskList = new HashMap(); + /*TaskBase currentTask; + HashMap taskList = new HashMap();*/ public Automaton(World world) { super(world); - this.texture = "/mods/tinker/textures/mob/automaton.png"; + this.setSize(0.9F, 2.42F); + this.texture = "/mods/tinker/textures/mob/crystalguardamber.png"; + this.tasks.addTask(1, new GAIAttackTarget(this)); + this.tasks.addTask(2, new GAIFindTarget(this)); + this.tasks.addTask(3, new GAIFollowOwner(this)); - taskList.put("wait", new TaskWait(this)); + /*taskList.put("wait", new TaskWait(this)); TaskBase task = new TaskClearcut(this); taskList.put("clearcut", task); - currentTask = task; + currentTask = task;*/ } @Override public void initCreature () { baseAttack = 5; - maxHealth = 30; + maxHealth = 50; } - @Override + /*@Override public void updateAITick() { if (!currentTask.update()) { currentTask.finishTask(); } - } + }*/ - @Override - protected boolean isAIEnabled() + protected String getHurtSound() { + return "mob.irongolem.hit"; + } + + /** + * Returns the sound this mob makes on death. + */ + protected String getDeathSound() + { + return "mob.irongolem.death"; + } + + /** + * Plays step sound at given x, y, z for the entity + */ + protected void playStepSound(int par1, int par2, int par3, int par4) + { + this.playSound("mob.irongolem.walk", 1.0F, 1.0F); + } + + public boolean interact(EntityPlayer par1EntityPlayer) + { + this.setCurrentItemOrArmor(0, par1EntityPlayer.getCurrentEquippedItem().copy()); return true; } } diff --git a/mods/tinker/tconstruct/entity/Crystal.java b/mods/tinker/tconstruct/entity/Crystal.java deleted file mode 100644 index c309f6c..0000000 --- a/mods/tinker/tconstruct/entity/Crystal.java +++ /dev/null @@ -1,21 +0,0 @@ -package mods.tinker.tconstruct.entity; - -import net.minecraft.entity.monster.EntityCreeper; -import net.minecraft.world.World; - -public class Crystal extends EntityCreeper -{ - - public Crystal(World par1World) - { - super(par1World); - this.texture = "/mods/tinker/textures/mob/crystalwater.png"; - } - - @Override - public int getMaxHealth () - { - return 100; - } - -} diff --git a/mods/tinker/tconstruct/entity/CrystalGuardian.java b/mods/tinker/tconstruct/entity/CrystalGuardian.java new file mode 100644 index 0000000..e2625e8 --- /dev/null +++ b/mods/tinker/tconstruct/entity/CrystalGuardian.java @@ -0,0 +1,21 @@ +package mods.tinker.tconstruct.entity; + +import net.minecraft.entity.EntityLiving; +import net.minecraft.world.World; + +public class CrystalGuardian extends EntityLiving +{ + + public CrystalGuardian(World par1World) + { + super(par1World); + this.texture = "/mods/tinker/textures/mob/crystalguardamber.png"; + } + + @Override + public int getMaxHealth () + { + return 100; + } + +} diff --git a/mods/tinker/tconstruct/entity/GolemBase.java b/mods/tinker/tconstruct/entity/GolemBase.java index d254d24..3b03561 100644 --- a/mods/tinker/tconstruct/entity/GolemBase.java +++ b/mods/tinker/tconstruct/entity/GolemBase.java @@ -1,30 +1,52 @@ package mods.tinker.tconstruct.entity; -import java.util.ArrayList; +import java.lang.ref.WeakReference; import java.util.Random; +import mods.tinker.tconstruct.library.tools.AbilityHelper; +import mods.tinker.tconstruct.library.tools.ToolCore; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.enchantment.EnchantmentThorns; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityCreature; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.IEntityMultiPart; +import net.minecraft.entity.boss.EntityDragonPart; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.potion.Potion; +import net.minecraft.util.DamageSource; +import net.minecraft.util.Icon; +import net.minecraft.util.MathHelper; import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; -public class GolemBase extends EntityCreature +public class GolemBase extends EntityCreature implements IInventory { - public String creator; + public WeakReference leader; //Monster + public String ownerName = ""; //Player public int maxHealth = 20; public int baseAttack; public boolean paused; - float bodyHeight; - float bodyWidth; - int movementType; - public int swings; - public int targetBlock[]; + int useTime; + protected static Random rand = new Random(); - public Entity escort; + public ItemStack[] inventory; public GolemBase(World world) { super(world); - //setInitialStats(); + setupInventory(); + } + + public void setupInventory () + { + inventory = new ItemStack[0]; } @Override @@ -33,234 +55,391 @@ public class GolemBase extends EntityCreature //Workaround for dying on spawn if (maxHealth == 0) return 20; - + return maxHealth; } @Override public void initCreature () { - //maxHealth = 20; baseAttack = 3; paused = false; } + public EntityLiving getOwner () + { + if (leader == null || leader.get() == null) + return this.worldObj.getPlayerEntityByName(ownerName); + return leader.get(); + } + + public void setOwner (EntityLiving living) + { + if (living instanceof EntityPlayer) + ownerName = ((EntityPlayer) living).username; + else + leader = new WeakReference(living); + } + + public boolean isOwner (Entity entity) + { + if (entity == null) + { + return false; + } + if (entity instanceof EntityPlayer) + { + EntityPlayer entityplayer = (EntityPlayer) entity; + return entityplayer.username.equalsIgnoreCase(ownerName); + } + return false; + } + + public float getSpeed () + { + return 0.25f; + } + /* AI */ + @Override + protected boolean isAIEnabled () + { + return true; + } + protected void updateWanderPath () { if (!paused) super.updateWanderPath(); } + public boolean following () + { + return false; + } + + public boolean patrolling () + { + return true; + } + + public void attackEntityAsGolem (Entity target) + { + ItemStack stack = getHeldItem(); + if (stack == null) + target.attackEntityFrom(DamageSource.causeMobDamage(this), baseAttack); + + if (stack.getItem() instanceof ToolCore) + { + if (stack.hasTagCompound()) + { + AbilityHelper.onLeftClickEntity(stack, this, target, (ToolCore) stack.getItem(), baseAttack); + } + else + target.attackEntityFrom(DamageSource.causeMobDamage(this), baseAttack); + } + else + { + if (target.canAttackWithItem()) + { + if (!target.func_85031_j(this)) + { + int i = stack.getDamageVsEntity(target) + baseAttack; + + if (this.isPotionActive(Potion.damageBoost)) + { + i += 3 << this.getActivePotionEffect(Potion.damageBoost).getAmplifier(); + } + + if (this.isPotionActive(Potion.weakness)) + { + i -= 2 << this.getActivePotionEffect(Potion.weakness).getAmplifier(); + } + + int j = 0; + int k = 0; + + if (target instanceof EntityLiving) + { + k = EnchantmentHelper.getEnchantmentModifierLiving(this, (EntityLiving) target); + j += EnchantmentHelper.getKnockbackModifier(this, (EntityLiving) target); + } + + if (this.isSprinting()) + { + ++j; + } + + if (i > 0 || k > 0) + { + boolean flag = this.fallDistance > 0.0F && !this.onGround && !this.isOnLadder() && !this.isInWater() && !this.isPotionActive(Potion.blindness) && this.ridingEntity == null + && target instanceof EntityLiving; + + if (flag && i > 0) + { + i += this.rand.nextInt(i / 2 + 2); + } + + i += k; + boolean flag1 = false; + int l = EnchantmentHelper.getFireAspectModifier(this); + + if (target instanceof EntityLiving && l > 0 && !target.isBurning()) + { + flag1 = true; + target.setFire(1); + } + + boolean flag2 = target.attackEntityFrom(DamageSource.causeMobDamage(this), i); + + if (flag2) + { + if (j > 0) + { + target.addVelocity((double) (-MathHelper.sin(this.rotationYaw * (float) Math.PI / 180.0F) * (float) j * 0.5F), 0.1D, + (double) (MathHelper.cos(this.rotationYaw * (float) Math.PI / 180.0F) * (float) j * 0.5F)); + this.motionX *= 0.6D; + this.motionZ *= 0.6D; + this.setSprinting(false); + } + + /*if (flag) + { + this.onCriticalHit(target); + } + + if (k > 0) + { + this.onEnchantmentCritical(target); + } + + if (i >= 18) + { + this.triggerAchievement(AchievementList.overkill); + }*/ + + this.setLastAttackingEntity(target); + + if (target instanceof EntityLiving) + { + EnchantmentThorns.func_92096_a(this, (EntityLiving) target, this.rand); + } + } + + //ItemStack stack = this.getCurrentEquippedItem(); + Object object = target; + + if (target instanceof EntityDragonPart) + { + IEntityMultiPart ientitymultipart = ((EntityDragonPart) target).entityDragonObj; + + if (ientitymultipart != null && ientitymultipart instanceof EntityLiving) + { + object = (EntityLiving) ientitymultipart; + } + } + + if (stack != null && object instanceof EntityLiving) + { + //stack.hitEntity((EntityLiving)object, this); + Item.itemsList[stack.itemID].hitEntity(stack, (EntityLiving) object, this); + + if (stack.stackSize <= 0) + { + this.destroyCurrentEquippedItem(); + } + } + + if (target instanceof EntityLiving) + { + /*if (target.isEntityAlive()) + { + this.alertWolves((EntityLiving)target, true); + } + + this.addStat(StatList.damageDealtStat, i);*/ + + if (l > 0 && flag2) + { + target.setFire(l * 4); + } + else if (flag1) + { + target.extinguish(); + } + } + + //this.addExhaustion(0.3F); + } + } + } + } + } + + public void destroyCurrentEquippedItem () + { + worldObj.playSoundAtEntity(this, "random.break", 0.5F, (rand.nextFloat() - rand.nextFloat()) * 0.2F + 1.0F); + this.setCurrentItemOrArmor(0, null); + } + /* Other */ protected boolean canDespawn () { return false; } - /* Effects */ - public void sparkle () + @Override + @SideOnly(Side.CLIENT) + public Icon getItemIcon (ItemStack par1ItemStack, int par2) { - Random random = worldObj.rand; - double d = (double) ((float) posX + random.nextFloat() * 2.0F) - 1.0D; - double d1 = (float) posY + random.nextFloat() * (float) bodyHeight; - double d2 = (double) ((float) posZ + random.nextFloat() * 2.0F) - 1.0D; - double d3 = (double) ((float) posX + random.nextFloat() * 2.0F) - 1.0D; - double d4 = (float) posY + random.nextFloat() * (float) bodyHeight; - double d5 = (double) ((float) posZ + random.nextFloat() * 2.0F) - 1.0D; - switch (0) - //(state) + Icon icon = super.getItemIcon(par1ItemStack, par2); + if (par1ItemStack.getItem().requiresMultipleRenderPasses()) { - case 0: - worldObj.spawnParticle("reddust", d, d1, d2, 0.0D, 1.0D, 0.0D); - worldObj.spawnParticle("reddust", d3, d4, d5, 0.0D, 1.0D, 0.0D); - break; + return par1ItemStack.getItem().getIcon(par1ItemStack, par2); + } - case 1: - worldObj.spawnParticle("reddust", d, d1, d2, -1D, 0.0D, 1.0D); - worldObj.spawnParticle("reddust", d3, d4, d5, -1D, 0.0D, 1.0D); - break; + return icon; + } - case 2: - worldObj.spawnParticle("reddust", d, d1, d2, 1.0D, 0.0D, 0.0D); - worldObj.spawnParticle("reddust", d3, d4, d5, 1.0D, 0.0D, 0.0D); - break; + @Override + public ItemStack getStackInSlot (int slot) + { + if (slot < 0 || slot >= inventory.length) + return null; + return inventory[slot]; + } - case 3: - worldObj.spawnParticle("reddust", d, d1, d2, 1.0D, 1.0D, 1.0D); - worldObj.spawnParticle("reddust", d3, d4, d5, 1.0D, 1.0D, 1.0D); - break; + public boolean isStackInSlot (int slot) + { + if (slot < 0 || slot >= inventory.length) + return false; + return inventory[slot] != null; + } - case 4: - worldObj.spawnParticle("reddust", d, d1, d2, 0.46000000000000002D, 0.28999999999999998D, 0.19D); - worldObj.spawnParticle("reddust", d3, d4, d5, 0.46000000000000002D, 0.28999999999999998D, 0.19D); - break; + @Override + public int getSizeInventory () + { + return inventory.length; + } + + @Override + public int getInventoryStackLimit () + { + return 64; + } + + @Override + public void setInventorySlotContents (int slot, ItemStack itemstack) + { + inventory[slot] = itemstack; + if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) + { + itemstack.stackSize = getInventoryStackLimit(); } } - public void sparkle (double d, double d1, double d2) + @Override + public ItemStack decrStackSize (int slot, int quantity) { - Random random = worldObj.rand; - double d3 = (double) ((float) posX + random.nextFloat() * 2.0F) - 1.0D; - double d4 = (float) posY + random.nextFloat() * (float) bodyHeight; - double d5 = (double) ((float) posZ + random.nextFloat() * 2.0F) - 1.0D; - double d6 = (double) ((float) posX + random.nextFloat() * 2.0F) - 1.0D; - double d7 = (float) posY + random.nextFloat() * (float) bodyHeight; - double d8 = (double) ((float) posZ + random.nextFloat() * 2.0F) - 1.0D; - worldObj.spawnParticle("reddust", d3, d4, d5, d, d1, d2); - worldObj.spawnParticle("reddust", d6, d7, d8, d, d1, d2); - } - - public void shineRadius (float f, double d, double d1, double d2) - { - shineRadius(f, d, d1, d2, 2, "reddust"); - } - - public void shineRadius (float f, double d, double d1, double d2, int i, String s) - { - d++; - Random random = new Random(); - float f1 = 0.7F; - float f2 = bodyHeight / 5; - for (int j = 1; j <= 2; j++) + if (inventory[slot] != null) { - float f3 = f / (float) j; - for (double d3 = 0.0D; d3 < 1.5707963D; d3 += 0.10000000000000001D) + if (inventory[slot].stackSize <= quantity) { - float f4 = (float) ((double) f3 * Math.cos(d3)); - float f5 = (float) ((double) f3 * Math.sin(d3)); - for (int k = 0; k < i; k++) - { - worldObj.spawnParticle(s, ((float) posX + f4 + random.nextFloat() * f1) - 0.5F, (float) posY + f2, ((float) posZ + f5 + random.nextFloat() * f1) - 0.5F, d, d1, d2); - } - - for (int l = 0; l < i; l++) - { - worldObj.spawnParticle(s, (((float) posX - f4) + random.nextFloat() * f1) - 0.5F, (float) posY + f2, ((float) posZ + f5 + random.nextFloat() * f1) - 0.5F, d, d1, d2); - } - - for (int i1 = 0; i1 < i; i1++) - { - worldObj.spawnParticle(s, ((float) posX + f4 + random.nextFloat() * f1) - 0.5F, (float) posY + f2, (((float) posZ - f5) + random.nextFloat() * f1) - 0.5F, d, d1, d2); - } - - for (int j1 = 0; j1 < i; j1++) - { - worldObj.spawnParticle(s, (((float) posX - f4) + random.nextFloat() * f1) - 0.5F, (float) posY + f2, (((float) posZ - f5) + random.nextFloat() * f1) - 0.5F, d, d1, d2); - } + ItemStack stack = inventory[slot]; + inventory[slot] = null; + return stack; } - } - } - - public void shineRadius (float f, double d, double d1, double d2, boolean flag) - { - d--; - Random random = new Random(); - float f1 = 0.7F; - float f2 = f; - String s = "reddust"; - float f3 = (float) bodyHeight / 5F; - for (double d3 = 0.0D; d3 < 1.5707963D; d3 += 0.20000000000000001D) - { - float f4 = (float) Math.sin(d3); - float f5 = (float) Math.cos(d3); - float f6 = f2 * f4; - for (double d4 = 0.0D; d4 < 1.5707963D; d4 += 0.20000000000000001D) + ItemStack split = inventory[slot].splitStack(quantity); + if (inventory[slot].stackSize == 0) { - float f7 = (float) Math.sin(d4); - float f8 = (float) Math.cos(d4); - float f9 = f2 * f8 * f5; - float f10 = f2 * f7 * f5; - worldObj.spawnParticle(s, ((float) posX + f9 + random.nextFloat() * f1) - 0.5F, (float) posY + f3 + f6 + random.nextFloat() * f1, - ((float) posZ + f10 + random.nextFloat() * f1) - 0.5F, d, d1, d2); - worldObj.spawnParticle(s, (((float) posX - f9) + random.nextFloat() * f1) - 0.5F, (float) posY + f3 + f6 + random.nextFloat() * f1, - ((float) posZ + f10 + random.nextFloat() * f1) - 0.5F, d, d1, d2); - worldObj.spawnParticle(s, ((float) posX + f9 + random.nextFloat() * f1) - 0.5F, (float) posY + f3 + f6 + random.nextFloat() * f1, - (((float) posZ - f10) + random.nextFloat() * f1) - 0.5F, d, d1, d2); - worldObj.spawnParticle(s, (((float) posX - f9) + random.nextFloat() * f1) - 0.5F, (float) posY + f3 + f6 + random.nextFloat() * f1, - (((float) posZ - f10) + random.nextFloat() * f1) - 0.5F, d, d1, d2); + inventory[slot] = null; } - } - } - - public ArrayList findNearbyBlock(int i, int j) - { - return findNearbyBlock(i, j, false); - } - - public ArrayList findNearbyBlock(int i, int j, boolean flag) - { - ArrayList arraylist = new ArrayList(); - int k = j; - int l = (int)posX; - int i1 = (int)posY; - int j1 = (int)posZ; - for (int k1 = 2; k1 >= -1; k1--) - { - for (int l1 = 0; l1 <= k; l1 = l1 <= 0 ? Math.abs(l1) + 1 : -l1) - { - for (int i2 = 0; i2 <= k; i2 = i2 <= 0 ? Math.abs(i2) + 1 : -i2) - { - int j2 = worldObj.getBlockId(l + l1, i1 + k1, j1 + i2); - if (j2 != 0 && j2 == i) - { - int ai[] = new int[3]; - ai[0] = l + l1; - ai[1] = i1 + k1; - ai[2] = j1 + i2; - arraylist.add(ai); - } - } - } - } - - return arraylist.size() == 0 ? null : arraylist; - } - - public boolean checkNeighbor(int ai[], int i) - { - int j = ai[0] + 1; - int l = ai[1] + 0; - int j1 = ai[2] + 0; - if (worldObj.getBlockId(j, l, j1) == i) - { - return true; - } - j = ai[0] + 0; - l = ai[1] + 1; - j1 = ai[2] + 0; - if (worldObj.getBlockId(j, l, j1) == i) - { - return true; - } - j = ai[0] + 0; - l = ai[1] + 0; - j1 = ai[2] + 1; - if (worldObj.getBlockId(j, l, j1) == i) - { - return true; - } - j = ai[0] - 1; - l = ai[1] + 0; - j1 = ai[2] + 0; - if (worldObj.getBlockId(j, l, j1) == i) - { - return true; - } - j = ai[0] + 0; - l = ai[1] - 1; - j1 = ai[2] + 0; - if (worldObj.getBlockId(j, l, j1) == i) - { - return true; + return split; } else { - int k = ai[0] + 0; - int i1 = ai[1] + 0; - int k1 = ai[2] - 1; - return worldObj.getBlockId(k, i1, k1) == i; + return null; + } + } + + @Override + public String getInvName () + { + return "tconstruct.knapsack"; + } + + @Override + public boolean isInvNameLocalized () + { + return false; + } + + @Override + public void onInventoryChanged () + { + + } + + public ItemStack getStackInSlotOnClosing (int slot) + { + return null; + } + + public void openChest () + { + } + + public void closeChest () + { + } + + @Override + public boolean isStackValidForSlot (int i, ItemStack itemstack) + { + return true; + } + + @Override + public boolean isUseableByPlayer (EntityPlayer entityplayer) + { + return true; + } + + public void writeEntityToNBT (NBTTagCompound tags) + { + super.writeEntityToNBT(tags); + tags.setString("OwnerName", ownerName); + NBTTagList nbttaglist = new NBTTagList(); + for (int iter = 0; iter < inventory.length; iter++) + { + if (inventory[iter] != null) + { + NBTTagCompound tagList = new NBTTagCompound(); + tagList.setByte("Slot", (byte) iter); + inventory[iter].writeToNBT(tagList); + nbttaglist.appendTag(tagList); + } + } + + tags.setTag("Items", nbttaglist); + + } + + public void readEntityFromNBT (NBTTagCompound tags) + { + super.readEntityFromNBT(tags); + ownerName = tags.getString("OwnerName"); + NBTTagList nbttaglist = tags.getTagList("Items"); + inventory = new ItemStack[getSizeInventory()]; + for (int iter = 0; iter < nbttaglist.tagCount(); iter++) + { + NBTTagCompound tagList = (NBTTagCompound) nbttaglist.tagAt(iter); + byte slotID = tagList.getByte("Slot"); + if (slotID >= 0 && slotID < inventory.length) + { + inventory[slotID] = ItemStack.loadItemStackFromNBT(tagList); + } } } } diff --git a/mods/tinker/tconstruct/entity/SlimeClone.java b/mods/tinker/tconstruct/entity/SlimeClone.java index b9e9fe8..b75cce9 100644 --- a/mods/tinker/tconstruct/entity/SlimeClone.java +++ b/mods/tinker/tconstruct/entity/SlimeClone.java @@ -3,6 +3,7 @@ package mods.tinker.tconstruct.entity; import mods.tinker.tconstruct.TConstruct; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; import net.minecraft.potion.Potion; import net.minecraft.util.MathHelper; import net.minecraft.world.World; @@ -52,7 +53,7 @@ public class SlimeClone extends GolemBase this.sizeHeight = this.sizeFactor; boolean flag = this.onGround; super.onUpdate(); - int i; + float i; if (this.onGround && !flag) { @@ -128,9 +129,9 @@ public class SlimeClone extends GolemBase return "blueslime"; } - public int getSlimeSize () + public float getSlimeSize () { - return 2; + return 1.5f; } /** @@ -149,6 +150,18 @@ public class SlimeClone extends GolemBase return this.getSlimeSize() > 2; } + public void writeEntityToNBT (NBTTagCompound tags) + { + super.writeEntityToNBT(tags); + tags.setString("Username", username); + } + + public void readEntityFromNBT (NBTTagCompound tags) + { + super.readEntityFromNBT(tags); + username = tags.getString("Username"); + } + @Override public void writeSpawnData (ByteArrayDataOutput data) { diff --git a/mods/tinker/tconstruct/entity/ai/GAIAttackTarget.java b/mods/tinker/tconstruct/entity/ai/GAIAttackTarget.java new file mode 100644 index 0000000..bb53f31 --- /dev/null +++ b/mods/tinker/tconstruct/entity/ai/GAIAttackTarget.java @@ -0,0 +1,142 @@ +package mods.tinker.tconstruct.entity.ai; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import mods.tinker.tconstruct.entity.GolemBase; +import mods.touhou_alice_dolls.DollRegistry; +import net.minecraft.entity.EntityList; +import net.minecraft.entity.EntityLiving; +import net.minecraft.pathfinding.PathNavigate; +import net.minecraft.util.DamageSource; + +public class GAIAttackTarget extends GolemAIBase +{ + private PathNavigate pathfinder; + private EntityLiving theTarget; + private float speed; + private int counter; + private boolean avoidsWater = true; + //public static String targetEntityRegex; + + public GAIAttackTarget(GolemBase doll) + { + super(doll); + this.speed = doll.getSpeed(); + this.pathfinder = doll.getNavigator(); + this.setMutexBits(3); + } + + @Override + public boolean shouldExecute () + { + if (golem.paused) + { + return false; + } + /*if (golem.isStandbyMode() || golem.isRideonMode()) + { + return false; + } + if (golem.getDollID() != DollRegistry.getDollID("Shanghai")) + { + return false; + }*/ + theTarget = golem.getAttackTarget(); + if (theTarget == null) + { + return false; + } + + String name = EntityList.getEntityString(theTarget); + if (name == null) + { + return false; + } + + /*Pattern targetPattern = Pattern.compile(targetEntityRegex); + Matcher targetMatcher = targetPattern.matcher(name); + + if (!targetMatcher.find()) + { + return false; + }*/ + + return true; + } + + @Override + public void startExecuting () + { + counter = 0; + this.avoidsWater = this.golem.getNavigator().getAvoidsWater(); + this.golem.getNavigator().setAvoidsWater(true); + } + + @Override + public boolean continueExecuting () + { + /* if (!golem.isEnable()) + { + return false; + } + if (golem.isStandbyMode() || golem.isRideonMode()) + { + return false; + }*/ + if (this.pathfinder.noPath()) + { + return false; + } + if (this.theTarget == null) + { + return false; + } + if (!this.theTarget.isEntityAlive()) + { + return false; + } + return true; + } + + @Override + public void resetTask () + { + this.theTarget = null; + this.pathfinder.clearPathEntity(); + this.golem.getNavigator().setAvoidsWater(this.avoidsWater); + } + + @Override + public void updateTask () + { + if (!this.pathfinder.noPath()) + { + this.golem.getLookHelper().setLookPositionWithEntity(this.theTarget, 10.0F, (float) this.golem.getVerticalFaceSpeed()); + } + + if (--this.counter <= 0) + { + this.counter = 20; + + this.pathfinder.tryMoveToEntityLiving(this.theTarget, this.speed); + if (this.golem.getDistanceSqToEntity(this.theTarget) < 9f && this.golem.getEntitySenses().canSee(this.theTarget)) + { + if (this.golem.getHeldItem() != null) + { + this.golem.swingItem(); + } + //theTarget.attackEntityFrom(DamageSource.causeMobDamage(golem), attackStrength); + golem.attackEntityAsGolem(theTarget); + + /*if (golem.getOwner() != null) + { + theTarget.attackEntityFrom(DamageSource.causePlayerDamage(golem.getOwner()), attackStrength); + } + else + {*/ + //} + } + } + } +} diff --git a/mods/tinker/tconstruct/entity/ai/GAIFindTarget.java b/mods/tinker/tconstruct/entity/ai/GAIFindTarget.java new file mode 100644 index 0000000..92be43a --- /dev/null +++ b/mods/tinker/tconstruct/entity/ai/GAIFindTarget.java @@ -0,0 +1,195 @@ +package mods.tinker.tconstruct.entity.ai; + +import java.util.List; + +import mods.tinker.tconstruct.entity.GolemBase; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityCreature; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.monster.EntityIronGolem; +import net.minecraft.entity.monster.IMob; +import net.minecraft.entity.passive.EntityChicken; +import net.minecraft.entity.passive.EntityMooshroom; +import net.minecraft.entity.passive.EntitySheep; + +public class GAIFindTarget extends GolemAIBase +{ + private int counter; + public static double searchRange = 16; + public static double searchHeight = 4; + public static String searchEntityRegex; + public static String targetEntityRegex; + + public GAIFindTarget(GolemBase golem) + { + super(golem); + this.setMutexBits(8); + } + + public boolean shouldExecute () + { + if (golem.paused) + { + return false; + } + return true; + } + + public void startExecuting () + { + counter = 0; + } + + public boolean continueExecuting () + { + return !golem.paused; + } + + public void updateTask () + { + if (counter == 0) + { + List targetList = (List) (world.getEntitiesWithinAABB(EntityLiving.class, golem.boundingBox.expand(searchRange, searchHeight, searchRange))); + /*Pattern searchPattern = Pattern.compile(searchEntityRegex); + Pattern targetPattern = Pattern.compile(targetEntityRegex); + Matcher searchMatcher, targetMatcher; + TreeMap entityCount = new TreeMap();*/ + EntityLiving theTarget = null; + EntityLiving stealTarget = null; + + theTarget = null; + for (EntityLiving e : targetList) + { + /*String name = EntityList.getEntityString(e); + if (name == null) + { + continue; + } + + searchMatcher = searchPattern.matcher(name); + if (searchMatcher.find()) + { + if (entityCount.containsKey(name)) + { + int c = entityCount.get(name).intValue() + 1; + entityCount.put(name, new Integer(c)); + } + else + { + entityCount.put(name, new Integer(1)); + } + }*/ + + //System.out.println("Entity: "+e); + if (golem.patrolling()) + { + //targetMatcher = targetPattern.matcher(name); + //if (targetMatcher.find()) + if (e instanceof IMob) + { + if (theTarget == null) + { + theTarget = e; + } + else + { + if (golem.getDistanceSqToEntity(theTarget) > golem.getDistanceSqToEntity(e)) + { + theTarget = e; + } + } + } + } + + if (golem.following()) + { + Entity tt = null; + if (e instanceof EntityCreature) + { + tt = ((EntityCreature) e).getEntityToAttack(); + } + else + { + tt = e.getAttackTarget(); + } + if (golem.isOwner(tt)) + { + if (theTarget == null) + { + theTarget = e; + } + else + { + if (golem.getDistanceSqToEntity(theTarget) > golem.getDistanceSqToEntity(e)) + { + theTarget = e; + } + } + } + } + + if (golem.patrolling()) + { + if (e instanceof EntitySheep) + { + EntitySheep sheep = (EntitySheep) e; + + if (!sheep.getSheared() && !sheep.isChild()) + { + if (stealTarget == null) + { + stealTarget = e; + } + else + { + if (golem.getDistanceSqToEntity(stealTarget) > golem.getDistanceSqToEntity(e)) + { + stealTarget = e; + } + } + } + } + else if (e instanceof EntityChicken || e instanceof EntityMooshroom || e instanceof EntityIronGolem) + { + if (stealTarget == null) + { + stealTarget = e; + } + else + { + if (golem.getDistanceSqToEntity(stealTarget) > golem.getDistanceSqToEntity(e)) + { + stealTarget = e; + } + } + } + } + } + + /*StringBuffer msg = new StringBuffer(golem.getDollName() + " : "); + + if (entityCount.isEmpty()) + { + msg.append("No target"); + golem.chatMessage(msg.toString(), 2); + } + else + { + Iterator it = entityCount.keySet().iterator(); + while (it.hasNext()) + { + String s = (String) it.next(); + int v = entityCount.get(s).intValue(); + msg.append(s); + msg.append("["); + msg.append(v); + msg.append("] "); + } + golem.chatMessage(msg.toString(), 1); + }*/ + + golem.setAttackTarget(theTarget == null ? stealTarget : theTarget); + } + counter = (counter + 1) % 20; + } +} diff --git a/mods/tinker/tconstruct/entity/ai/GAIFollowOwner.java b/mods/tinker/tconstruct/entity/ai/GAIFollowOwner.java new file mode 100644 index 0000000..a99eb9e --- /dev/null +++ b/mods/tinker/tconstruct/entity/ai/GAIFollowOwner.java @@ -0,0 +1,114 @@ +package mods.tinker.tconstruct.entity.ai; + +import mods.tinker.tconstruct.entity.GolemBase; +import net.minecraft.entity.EntityLiving; +import net.minecraft.pathfinding.PathNavigate; +import net.minecraft.util.MathHelper; + +public class GAIFollowOwner extends GolemAIBase +{ + private EntityLiving leader; + private float speed; + private float maxDist; + private float minDist; + private PathNavigate pathfinder; + private boolean avoidsWater; + private int counter; + + public GAIFollowOwner(GolemBase golem) + { + super(golem); + this.speed = golem.getSpeed(); + this.minDist = 4.0f; + this.maxDist = 2.5f; + this.pathfinder = golem.getNavigator(); + this.setMutexBits(3); + } + + public boolean shouldExecute () + { + EntityLiving owner = this.golem.getOwner(); + + if (owner == null) + { + return false; + } + /*if (!this.golem.isFollowMode()) + { + return false; + }*/ + if (this.golem.getDistanceSqToEntity(owner) < (double) (this.minDist * this.minDist)) + { + return false; + } + + this.leader = owner; + return true; + } + + public boolean continueExecuting () + { + if (this.pathfinder.noPath()) + { + return false; + } + if (this.golem.getDistanceSqToEntity(this.leader) < (double) (this.maxDist * this.maxDist)) + { + return false; + } + /*if (!this.golem.isFollowMode()) + { + return false; + }*/ + return true; + } + + public void startExecuting () + { + this.counter = 0; + this.avoidsWater = this.golem.getNavigator().getAvoidsWater(); + this.golem.getNavigator().setAvoidsWater(false); + } + + public void resetTask () + { + this.leader = null; + this.pathfinder.clearPathEntity(); + this.golem.getNavigator().setAvoidsWater(this.avoidsWater); + } + + public void updateTask () + { + this.golem.getLookHelper().setLookPositionWithEntity(this.leader, 10.0F, (float) this.golem.getVerticalFaceSpeed()); + + if (--this.counter <= 0) + { + this.counter = 10; + + if (!this.pathfinder.tryMoveToEntityLiving(this.leader, this.speed)) + { + if (this.golem.getDistanceSqToEntity(this.leader) >= 144.0D) + { + int var1 = MathHelper.floor_double(this.leader.posX) - 2; + int var2 = MathHelper.floor_double(this.leader.posZ) - 2; + int var3 = MathHelper.floor_double(this.leader.boundingBox.minY); + + for (int var4 = 0; var4 <= 4; ++var4) + { + for (int var5 = 0; var5 <= 4; ++var5) + { + if ((var4 < 1 || var5 < 1 || var4 > 3 || var5 > 3) && this.world.doesBlockHaveSolidTopSurface(var1 + var4, var3 - 1, var2 + var5) + && !this.world.isBlockNormalCube(var1 + var4, var3, var2 + var5) && !this.world.isBlockNormalCube(var1 + var4, var3 + 1, var2 + var5)) + { + this.golem.setLocationAndAngles((double) ((float) (var1 + var4) + 0.5F), (double) var3, (double) ((float) (var2 + var5) + 0.5F), this.golem.rotationYaw, + this.golem.rotationPitch); + this.pathfinder.clearPathEntity(); + return; + } + } + } + } + } + } + } +} diff --git a/mods/tinker/tconstruct/entity/ai/GolemAIBase.java b/mods/tinker/tconstruct/entity/ai/GolemAIBase.java new file mode 100644 index 0000000..2913d72 --- /dev/null +++ b/mods/tinker/tconstruct/entity/ai/GolemAIBase.java @@ -0,0 +1,23 @@ +package mods.tinker.tconstruct.entity.ai; + +import mods.tinker.tconstruct.entity.GolemBase; +import net.minecraft.entity.ai.EntityAIBase; +import net.minecraft.world.World; + +public class GolemAIBase extends EntityAIBase +{ + protected GolemBase golem; + protected World world; + + public GolemAIBase(GolemBase entity) + { + golem = entity; + world = entity.worldObj; + } + + @Override + public boolean shouldExecute() + { + return false; + } +} diff --git a/mods/tinker/tconstruct/entity/ai/TaskBase.java b/mods/tinker/tconstruct/entity/ai/TaskBase.java deleted file mode 100644 index 24c15b1..0000000 --- a/mods/tinker/tconstruct/entity/ai/TaskBase.java +++ /dev/null @@ -1,40 +0,0 @@ -package mods.tinker.tconstruct.entity.ai; - -import java.util.List; - -import mods.tinker.tconstruct.entity.GolemBase; -import net.minecraft.block.Block; -import net.minecraft.entity.Entity; -import net.minecraft.entity.ai.EntityAITasks; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.DamageSource; -import net.minecraft.util.EnumMovingObjectType; -import net.minecraft.util.MovingObjectPosition; -import net.minecraft.util.Vec3; -import net.minecraft.world.World; - -public abstract class TaskBase -{ - public final GolemBase owner; - - public TaskBase(GolemBase golem) - { - this.owner = golem; - } - - public void init() {} - - public void saveTask(NBTTagCompound var1) {} - public void loadTask(NBTTagCompound var1) {} - - public abstract boolean update(); - public void finishTask() {} - - public int getPriority() - { - return 0; - } -} diff --git a/mods/tinker/tconstruct/entity/ai/TaskClearcut.java b/mods/tinker/tconstruct/entity/ai/TaskClearcut.java deleted file mode 100644 index 895e352..0000000 --- a/mods/tinker/tconstruct/entity/ai/TaskClearcut.java +++ /dev/null @@ -1,52 +0,0 @@ -package mods.tinker.tconstruct.entity.ai; - -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.block.Block; - -import mods.tinker.tconstruct.entity.GolemBase; -import mods.tinker.tconstruct.library.util.CoordTuple; - -public class TaskClearcut extends TaskBase -{ - boolean moving; - boolean searching; - List blocks = new ArrayList(); - public TaskClearcut(GolemBase golem) - { - super(golem); - } - - public boolean update () - { - if (searching) - { - searchForBlocks(); - } - return true; - } - - void searchForBlocks() - { - for (int x = -7; x <= 7; x++) - { - for (int z = -7; z <= 7; z++) - { - for (int y = -1; y <= 1; y++) - { - Block block = Block.blocksList[owner.worldObj.getBlockId((int)owner.posX+x, (int)owner.posY+y, (int)owner.posZ+z)]; - if (block != null && block.isWood(owner.worldObj, (int)owner.posX+x, (int)owner.posY+y, (int)owner.posZ+z)) - { - blocks.add(new CoordTuple((int)owner.posX+x, (int)owner.posY+y, (int)owner.posZ+z)); - } - } - } - } - } - - public void finishTask() - { - moving = false; - } -} diff --git a/mods/tinker/tconstruct/entity/ai/TaskWait.java b/mods/tinker/tconstruct/entity/ai/TaskWait.java deleted file mode 100644 index 01dd265..0000000 --- a/mods/tinker/tconstruct/entity/ai/TaskWait.java +++ /dev/null @@ -1,17 +0,0 @@ -package mods.tinker.tconstruct.entity.ai; - -import mods.tinker.tconstruct.entity.GolemBase; - -public class TaskWait extends TaskBase -{ - public TaskWait(GolemBase golem) - { - super(golem); - } - - @Override - public boolean update () - { - return true; - } -} diff --git a/mods/tinker/tconstruct/items/CraftingItem.java b/mods/tinker/tconstruct/items/CraftingItem.java index a179a6c..0d6542e 100644 --- a/mods/tinker/tconstruct/items/CraftingItem.java +++ b/mods/tinker/tconstruct/items/CraftingItem.java @@ -32,7 +32,8 @@ public class CraftingItem extends Item @SideOnly(Side.CLIENT) public Icon getIconFromDamage(int meta) { - return icons[meta]; + int arr = MathHelper.clamp_int(meta, 0, unlocalizedNames.length); + return icons[arr]; } @SideOnly(Side.CLIENT) diff --git a/mods/tinker/tconstruct/items/GoldenHead.java b/mods/tinker/tconstruct/items/GoldenHead.java new file mode 100644 index 0000000..17462d2 --- /dev/null +++ b/mods/tinker/tconstruct/items/GoldenHead.java @@ -0,0 +1,83 @@ +package mods.tinker.tconstruct.items; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemFood; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.Icon; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class GoldenHead extends ItemFood +{ + public GoldenHead(int par1, int par2, float par3, boolean par4) + { + super(par1, par2, par3, par4); + this.setHasSubtypes(true); + } + + @SideOnly(Side.CLIENT) + public boolean hasEffect(ItemStack par1ItemStack) + { + return par1ItemStack.getItemDamage() > 0; + } + + @SideOnly(Side.CLIENT) + + /** + * Return an item rarity from EnumRarity + */ + public EnumRarity getRarity(ItemStack par1ItemStack) + { + return par1ItemStack.getItemDamage() == 0 ? EnumRarity.rare : EnumRarity.epic; + } + + protected void onFoodEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) + { + if (par1ItemStack.getItemDamage() > 0) + { + if (!par2World.isRemote) + { + par3EntityPlayer.addPotionEffect(new PotionEffect(Potion.regeneration.id, 600, 3)); + par3EntityPlayer.addPotionEffect(new PotionEffect(Potion.resistance.id, 6000, 0)); + par3EntityPlayer.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 6000, 0)); + } + } + else + { + super.onFoodEaten(par1ItemStack, par2World, par3EntityPlayer); + } + } + + @SideOnly(Side.CLIENT) + + /** + * returns a list of items with the same ID, but different meta (eg: dye returns 16 items) + */ + public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List) + { + par3List.add(new ItemStack(par1, 1, 0)); + } + + + + @SideOnly(Side.CLIENT) + @Override + public void registerIcons(IconRegister iconRegister) + { + this.itemIcon = iconRegister.registerIcon("tinker:skull_char_gold"); + /*this.icons = new Icon[textureNames.length]; + + for (int i = 0; i < this.icons.length; ++i) + { + this.icons[i] = iconRegister.registerIcon("tinker:"+textureNames[i]); + }*/ + } +} diff --git a/mods/tinker/tconstruct/items/tools/Battleaxe.java b/mods/tinker/tconstruct/items/tools/Battleaxe.java index 2d8d8ca..1bc1280 100644 --- a/mods/tinker/tconstruct/items/tools/Battleaxe.java +++ b/mods/tinker/tconstruct/items/tools/Battleaxe.java @@ -267,12 +267,20 @@ public class Battleaxe extends HarvestTool if (block != null && block.blockMaterial == Material.wood) { meta = world.getBlockMetadata(x, yPos, z); - world.setBlockToAir(x, yPos, z); + /*world.setBlockToAir(x, yPos, z); if (!player.capabilities.isCreativeMode) { Block.blocksList[blockID].harvestBlock(world, player, x, yPos, z, meta); onBlockDestroyed(stack, world, blockID, x, yPos, z, player); + }*/ + if (!player.capabilities.isCreativeMode) + { + block.harvestBlock(world, player, x, yPos, z, meta); + block.onBlockHarvested(world, x, y, z, meta, player); + onBlockDestroyed(stack, world, localblockID, x, yPos, z, player); } + world.setBlockToAir(x, yPos, z); + blockID = localblockID; } } } diff --git a/mods/tinker/tconstruct/items/tools/Excavator.java b/mods/tinker/tconstruct/items/tools/Excavator.java index a8b3b42..12a867b 100644 --- a/mods/tinker/tconstruct/items/tools/Excavator.java +++ b/mods/tinker/tconstruct/items/tools/Excavator.java @@ -145,6 +145,9 @@ public class Excavator extends HarvestTool Block block = Block.blocksList[blockID]; if (!stack.hasTagCompound()) return false; + + if (block == null) + return super.onBlockStartBreak(stack, x, y, z, player); boolean validStart = false; for (int iter = 0; iter < materials.length; iter++) @@ -209,12 +212,20 @@ public class Excavator extends HarvestTool { if (materials[iter] == block.blockMaterial) { - world.setBlockToAir(xPos, yPos, zPos); + /*world.setBlockToAir(xPos, yPos, zPos); if (!player.capabilities.isCreativeMode) { block.harvestBlock(world, player, xPos, yPos, zPos, meta); onBlockDestroyed(stack, world, localblockID, xPos, yPos, zPos, player); } + blockID = localblockID;*/ + if (!player.capabilities.isCreativeMode) + { + block.harvestBlock(world, player, xPos, yPos, zPos, meta); + block.onBlockHarvested(world, x, y, z, meta, player); + onBlockDestroyed(stack, world, localblockID, xPos, yPos, zPos, player); + } + world.setBlockToAir(xPos, yPos, zPos); blockID = localblockID; } } @@ -231,6 +242,55 @@ public class Excavator extends HarvestTool } @Override + public float getStrVsBlock (ItemStack stack, Block block, int meta) + { + if (!stack.hasTagCompound()) + return 1.0f; + + NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool"); + if (tags.getBoolean("Broken")) + return 0.1f; + + Material[] materials = getEffectiveMaterials(); + for (int i = 0; i < materials.length; i++) + { + if (materials[i] == block.blockMaterial) + { + float mineSpeed = tags.getInteger("MiningSpeed"); + int heads = 1; + if (tags.hasKey("MiningSpeed2")) + { + mineSpeed += tags.getInteger("MiningSpeed2"); + heads++; + } + + if (tags.hasKey("MiningSpeedHandle")) + { + mineSpeed += tags.getInteger("MiningSpeedHandle"); + heads++; + } + + if (tags.hasKey("MiningSpeedExtra")) + { + mineSpeed += tags.getInteger("MiningSpeedExtra"); + heads++; + } + float trueSpeed = mineSpeed / (heads * 300f); + int hlvl = MinecraftForge.getBlockHarvestLevel(block, meta, getHarvestType()); + int durability = tags.getInteger("Damage"); + + float stonebound = tags.getFloat("Shoddy"); + float bonusLog = (float) Math.log(durability / 72f + 1) * 2 * stonebound; + trueSpeed += bonusLog; + + if (hlvl <= tags.getInteger("HarvestLevel")) + return trueSpeed; + return 0.1f; + } + } + return super.getStrVsBlock(stack, block, meta); + } + /*@Override public void onUpdate (ItemStack stack, World world, Entity entity, int par4, boolean par5) { super.onUpdate(stack, world, entity, par4, par5); @@ -243,5 +303,5 @@ public class Excavator extends HarvestTool player.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, 1, 1)); } } - } + }*/ } diff --git a/mods/tinker/tconstruct/items/tools/Hammer.java b/mods/tinker/tconstruct/items/tools/Hammer.java index 58f3c3f..bbb27ba 100644 --- a/mods/tinker/tconstruct/items/tools/Hammer.java +++ b/mods/tinker/tconstruct/items/tools/Hammer.java @@ -208,105 +208,6 @@ public class Hammer extends HarvestTool ArrayList coords = new ArrayList(); - /*@Override - public boolean onBlockDestroyed (ItemStack stack, World world, int blockID, int x, int y, int z, EntityLiving entity) - { - System.out.println("Rawr!"); - //return AbilityHelper.onBlockChanged(stack, world, blockID, x, y, z, player, random); - int localID = blockID; - int meta = world.getBlockMetadata(x, y, z); - Block block = Block.blocksList[blockID]; - if (!stack.hasTagCompound()) - return false; - - boolean validStart = false; - for (int iter = 0; iter < materials.length; iter++) - { - if (materials[iter] == block.blockMaterial) - { - validStart = true; - break; - } - } - - MovingObjectPosition mop = AbilityHelper.raytraceFromEntity(world, entity, true, 6); - if (mop == null || !validStart) - return AbilityHelper.onBlockChanged(stack, world, blockID, x, y, z, entity, random); - - int xRange = 1; - int yRange = 1; - int zRange = 1; - switch (mop.sideHit) - { - case 0: - case 1: - yRange = 0; - break; - case 2: - case 3: - zRange = 0; - break; - case 4: - case 5: - xRange = 0; - break; - } - NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool"); - for (int xPos = x - xRange; xPos <= x + xRange; xPos++) - { - for (int yPos = y - yRange; yPos <= y + yRange; yPos++) - { - for (int zPos = z - zRange; zPos <= z + zRange; zPos++) - { - if (!(tags.getBoolean("Broken"))) - { - int localblockID = world.getBlockId(xPos, yPos, zPos); - block = Block.blocksList[localblockID]; - meta = world.getBlockMetadata(xPos, yPos, zPos); - int hlvl = MinecraftForge.getBlockHarvestLevel(block, meta, getHarvestType()); - - if (hlvl <= tags.getInteger("HarvestLevel")) - { - boolean cancelHarvest = false; - for (ActiveToolMod mod : TConstructRegistry.activeModifiers) - { - if (mod.beforeBlockBreak(this, stack, xPos, yPos, zPos, entity)) - cancelHarvest = true; - } - - if (!cancelHarvest) - { - if (block != null && !(block.blockHardness < 0)) - { - for (int iter = 0; iter < materials.length; iter++) - { - if (materials[iter] == block.blockMaterial) - { - world.setBlockToAir(xPos, yPos, zPos); - if (entity instanceof EntityPlayer) - { - if (!((EntityPlayer) entity).capabilities.isCreativeMode) - { - block.harvestBlock(world, (EntityPlayer) entity, xPos, yPos, zPos, meta); - AbilityHelper.onBlockChanged(stack, world, blockID, x, y, z, entity, random); - } - } - localID = localblockID; - } - } - } - } - } - } - } - } - } - AbilityHelper.onBlockChanged(stack, world, blockID, x, y, z, entity, random); - if (!world.isRemote) - world.playAuxSFX(2001, x, y, z, localID + (meta << 12)); - return true; - }*/ - @Override public boolean onBlockStartBreak (ItemStack stack, int x, int y, int z, EntityPlayer player) { @@ -317,6 +218,9 @@ public class Hammer extends HarvestTool if (!stack.hasTagCompound()) return false; + if (block == null) + return super.onBlockStartBreak(stack, x, y, z, player); + boolean validStart = false; for (int iter = 0; iter < materials.length; iter++) { @@ -380,12 +284,13 @@ public class Hammer extends HarvestTool { if (materials[iter] == block.blockMaterial) { - world.setBlockToAir(xPos, yPos, zPos); if (!player.capabilities.isCreativeMode) { block.harvestBlock(world, player, xPos, yPos, zPos, meta); + block.onBlockHarvested(world, x, y, z, meta, player); onBlockDestroyed(stack, world, localblockID, xPos, yPos, zPos, player); } + world.setBlockToAir(xPos, yPos, zPos); blockID = localblockID; } } @@ -400,8 +305,58 @@ public class Hammer extends HarvestTool world.playAuxSFX(2001, x, y, z, blockID + (meta << 12)); return true; } - + @Override + public float getStrVsBlock (ItemStack stack, Block block, int meta) + { + if (!stack.hasTagCompound()) + return 1.0f; + + NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool"); + if (tags.getBoolean("Broken")) + return 0.1f; + + Material[] materials = getEffectiveMaterials(); + for (int i = 0; i < materials.length; i++) + { + if (materials[i] == block.blockMaterial) + { + float mineSpeed = tags.getInteger("MiningSpeed"); + int heads = 1; + if (tags.hasKey("MiningSpeed2")) + { + mineSpeed += tags.getInteger("MiningSpeed2"); + heads++; + } + + if (tags.hasKey("MiningSpeedHandle")) + { + mineSpeed += tags.getInteger("MiningSpeedHandle"); + heads++; + } + + if (tags.hasKey("MiningSpeedExtra")) + { + mineSpeed += tags.getInteger("MiningSpeedExtra"); + heads++; + } + float trueSpeed = mineSpeed / (heads * 300f); + int hlvl = MinecraftForge.getBlockHarvestLevel(block, meta, getHarvestType()); + int durability = tags.getInteger("Damage"); + + float stonebound = tags.getFloat("Shoddy"); + float bonusLog = (float) Math.log(durability / 72f + 1) * 2 * stonebound; + trueSpeed += bonusLog; + + if (hlvl <= tags.getInteger("HarvestLevel")) + return trueSpeed; + return 0.1f; + } + } + return super.getStrVsBlock(stack, block, meta); + } + + /*@Override public void onUpdate (ItemStack stack, World world, Entity entity, int par4, boolean par5) { super.onUpdate(stack, world, entity, par4, par5); @@ -414,7 +369,7 @@ public class Hammer extends HarvestTool player.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, 1, 1)); } } - } + }*/ @Override public String[] toolCategories () diff --git a/mods/tinker/tconstruct/items/tools/LumberAxe.java b/mods/tinker/tconstruct/items/tools/LumberAxe.java index d655c6b..8cb50d7 100644 --- a/mods/tinker/tconstruct/items/tools/LumberAxe.java +++ b/mods/tinker/tconstruct/items/tools/LumberAxe.java @@ -74,7 +74,7 @@ public class LumberAxe extends HarvestTool /* Lumber axe specific */ - @Override + /*@Override public void onUpdate (ItemStack stack, World world, Entity entity, int par4, boolean par5) { super.onUpdate(stack, world, entity, par4, par5); @@ -87,6 +87,56 @@ public class LumberAxe extends HarvestTool player.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, 1, 1)); } } + }*/ + + @Override + public float getStrVsBlock (ItemStack stack, Block block, int meta) + { + if (!stack.hasTagCompound()) + return 1.0f; + + NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool"); + if (tags.getBoolean("Broken")) + return 0.1f; + + Material[] materials = getEffectiveMaterials(); + for (int i = 0; i < materials.length; i++) + { + if (materials[i] == block.blockMaterial) + { + float mineSpeed = tags.getInteger("MiningSpeed"); + int heads = 1; + if (tags.hasKey("MiningSpeed2")) + { + mineSpeed += tags.getInteger("MiningSpeed2"); + heads++; + } + + if (tags.hasKey("MiningSpeedHandle")) + { + mineSpeed += tags.getInteger("MiningSpeedHandle"); + heads++; + } + + if (tags.hasKey("MiningSpeedExtra")) + { + mineSpeed += tags.getInteger("MiningSpeedExtra"); + heads++; + } + float trueSpeed = mineSpeed / (heads * 300f); + int hlvl = MinecraftForge.getBlockHarvestLevel(block, meta, getHarvestType()); + int durability = tags.getInteger("Damage"); + + float stonebound = tags.getFloat("Shoddy"); + float bonusLog = (float) Math.log(durability / 72f + 1) * 2 * stonebound; + trueSpeed += bonusLog; + + if (hlvl <= tags.getInteger("HarvestLevel")) + return trueSpeed; + return 0.1f; + } + } + return super.getStrVsBlock(stack, block, meta); } @Override @@ -173,12 +223,19 @@ public class LumberAxe extends HarvestTool { if (localblockID == bID && world.getBlockMetadata(xPos, yPos, zPos) % 4 == meta % 4) { - world.setBlock(xPos, yPos, zPos, 0, 0, 4); + /* world.setBlock(xPos, yPos, zPos, 0, 0, 3); if (!player.capabilities.isCreativeMode) { Block.blocksList[bID].harvestBlock(world, player, xPos, yPos, zPos, meta); onBlockDestroyed(stack, world, bID, xPos, yPos, zPos, player); + }*/ + if (!player.capabilities.isCreativeMode) + { + block.harvestBlock(world, player, xPos, yPos, zPos, meta); + block.onBlockHarvested(world, x, y, z, meta, player); + onBlockDestroyed(stack, world, localblockID, xPos, yPos, zPos, player); } + world.setBlockToAir(xPos, yPos, zPos); breakTree(world, xPos, yPos, zPos, stack, tags, bID, meta, player); } /*else diff --git a/mods/tinker/tconstruct/items/tools/Scythe.java b/mods/tinker/tconstruct/items/tools/Scythe.java index 92980a7..a318468 100644 --- a/mods/tinker/tconstruct/items/tools/Scythe.java +++ b/mods/tinker/tconstruct/items/tools/Scythe.java @@ -182,12 +182,20 @@ public class Scythe extends Weapon if (materials[iter] == block.blockMaterial) { meta = world.getBlockMetadata(xPos, yPos, zPos); - world.setBlockToAir(xPos, yPos, zPos); + /*world.setBlockToAir(xPos, yPos, zPos); if (!player.capabilities.isCreativeMode) { block.harvestBlock(world, player, xPos, yPos, zPos, meta); onBlockDestroyed(stack, world, localblockID, xPos, yPos, zPos, player); } + blockID = localblockID;*/ + if (!player.capabilities.isCreativeMode) + { + block.harvestBlock(world, player, xPos, yPos, zPos, meta); + block.onBlockHarvested(world, x, y, z, meta, player); + onBlockDestroyed(stack, world, localblockID, xPos, yPos, zPos, player); + } + world.setBlockToAir(xPos, yPos, zPos); blockID = localblockID; } } diff --git a/mods/tinker/tconstruct/library/ActiveToolMod.java b/mods/tinker/tconstruct/library/ActiveToolMod.java index 760a20a..8bffb24 100644 --- a/mods/tinker/tconstruct/library/ActiveToolMod.java +++ b/mods/tinker/tconstruct/library/ActiveToolMod.java @@ -29,18 +29,18 @@ public class ActiveToolMod /* Attacking */ - public int baseAttackDamage(int earlyModDamage, int damage, ToolCore tool, NBTTagCompound tags, NBTTagCompound toolTags, ItemStack stack, EntityPlayer player, Entity entity) + public int baseAttackDamage(int earlyModDamage, int damage, ToolCore tool, NBTTagCompound tags, NBTTagCompound toolTags, ItemStack stack, EntityLiving player, Entity entity) { return 0; } //Calculated after sprinting and enchant bonuses - public float knockback(float modKnockback, float currentKnockback, ToolCore tool, NBTTagCompound tags, NBTTagCompound toolTags, ItemStack stack, EntityPlayer player, Entity entity) + public float knockback(float modKnockback, float currentKnockback, ToolCore tool, NBTTagCompound tags, NBTTagCompound toolTags, ItemStack stack, EntityLiving player, Entity entity) { return 0f; } - public int attackDamage(int modDamage, int currentDamage, ToolCore tool, NBTTagCompound tags, NBTTagCompound toolTags, ItemStack stack, EntityPlayer player, Entity entity) + public int attackDamage(int modDamage, int currentDamage, ToolCore tool, NBTTagCompound tags, NBTTagCompound toolTags, ItemStack stack, EntityLiving player, Entity entity) { return 0; } diff --git a/mods/tinker/tconstruct/library/TConstructRegistry.java b/mods/tinker/tconstruct/library/TConstructRegistry.java index 540148b..9501aa6 100644 --- a/mods/tinker/tconstruct/library/TConstructRegistry.java +++ b/mods/tinker/tconstruct/library/TConstructRegistry.java @@ -56,7 +56,7 @@ public class TConstructRegistry public static void addItemToDirectory(String name, Item itemstack) { Item add = itemDirectory.get(name); - if (add == null) + if (add != null) System.out.println("[TCon API] "+name+" is already present in the Item directory"); itemDirectory.put(name, itemstack); @@ -102,7 +102,7 @@ public class TConstructRegistry public static void addItemStackToDirectory(String name, ItemStack itemstack) { ItemStack add = itemstackDirectory.get(name); - if (add == null) + if (add != null) System.out.println("[TCon API] "+name+" is already present in the ItemStack directory"); itemstackDirectory.put(name, itemstack); diff --git a/mods/tinker/tconstruct/library/blocks/InventoryBlock.java b/mods/tinker/tconstruct/library/blocks/InventoryBlock.java index ab67cfc..2622c94 100644 --- a/mods/tinker/tconstruct/library/blocks/InventoryBlock.java +++ b/mods/tinker/tconstruct/library/blocks/InventoryBlock.java @@ -55,7 +55,7 @@ public abstract class InventoryBlock extends BlockContainer /* Inventory */ @Override - public void breakBlock (World par1World, int x, int y, int z, int par5, int par6) + public void breakBlock (World par1World, int x, int y, int z, int par5, int meta) { TileEntity te = par1World.getBlockTileEntity(x, y, z); @@ -100,7 +100,7 @@ public abstract class InventoryBlock extends BlockContainer } } - super.breakBlock(par1World, x, y, z, par5, par6); + super.breakBlock(par1World, x, y, z, par5, meta); } /* Placement */ diff --git a/mods/tinker/tconstruct/library/crafting/CastingRecipe.java b/mods/tinker/tconstruct/library/crafting/CastingRecipe.java index 62203d2..e06e12a 100644 --- a/mods/tinker/tconstruct/library/crafting/CastingRecipe.java +++ b/mods/tinker/tconstruct/library/crafting/CastingRecipe.java @@ -20,9 +20,9 @@ public class CastingRecipe coolTime = delay; } - public boolean matches(LiquidStack metal, ItemStack cast) + public boolean matches(LiquidStack metal, ItemStack inputCast) { - if (castingMetal.isLiquidEqual(metal) && ItemStack.areItemStacksEqual(this.cast, cast)) + if (castingMetal.isLiquidEqual(metal) && ((cast != null && cast.itemDamage == Short.MAX_VALUE && inputCast.getItem() == cast.getItem()) || ItemStack.areItemStacksEqual(this.cast, inputCast)) ) return true; else return false; diff --git a/mods/tinker/tconstruct/library/crafting/LiquidCasting.java b/mods/tinker/tconstruct/library/crafting/LiquidCasting.java index 57441dd..53d9bca 100644 --- a/mods/tinker/tconstruct/library/crafting/LiquidCasting.java +++ b/mods/tinker/tconstruct/library/crafting/LiquidCasting.java @@ -49,6 +49,11 @@ public class LiquidCasting { addCastingRecipe(output, metal, null, false, delay); } + + public void addCustomCastingRecipe(CastingRecipe recipe) + { + casts.add(recipe); + } public int getCastingDelay (LiquidStack metal, ItemStack cast) { diff --git a/mods/tinker/tconstruct/library/tools/AbilityHelper.java b/mods/tinker/tconstruct/library/tools/AbilityHelper.java index 980547c..4a2f066 100644 --- a/mods/tinker/tconstruct/library/tools/AbilityHelper.java +++ b/mods/tinker/tconstruct/library/tools/AbilityHelper.java @@ -22,6 +22,7 @@ import net.minecraft.entity.monster.EntityGhast; import net.minecraft.entity.passive.EntityWolf; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.Potion; @@ -40,595 +41,626 @@ import net.minecraftforge.event.entity.player.UseHoeEvent; public class AbilityHelper { - static Random random = new Random(); - - /* Normal interactions */ - public static boolean onBlockChanged (ItemStack stack, World world, int bID, int x, int y, int z, EntityLiving player, Random random) - { - if (!stack.hasTagCompound()) - return false; - - int reinforced = 0; - NBTTagCompound tags = stack.getTagCompound(); - - if (tags.getCompoundTag("InfiTool").hasKey("Unbreaking")) - reinforced = tags.getCompoundTag("InfiTool").getInteger("Unbreaking"); - - if (random.nextInt(10) < 10 - reinforced) - { - damageTool(stack, 1, tags, player, false); - } - - return true; - } - - public static boolean onLeftClickEntity (ItemStack stack, EntityPlayer player, Entity entity, ToolCore tool) - { - if (entity.canAttackWithItem() && stack.hasTagCompound()) - { - if (!entity.func_85031_j(player)) // can't attack this entity - { - NBTTagCompound tags = stack.getTagCompound(); - NBTTagCompound toolTags = stack.getTagCompound().getCompoundTag("InfiTool"); - int damage = toolTags.getInteger("Attack"); - boolean broken = toolTags.getBoolean("Broken"); - - int durability = tags.getCompoundTag("InfiTool").getInteger("Damage"); - float stonebound = tags.getCompoundTag("InfiTool").getFloat("Shoddy"); - - float stoneboundDamage = (float) Math.log(durability / 72f + 1) * -2 * stonebound; - - int earlyModDamage = 0; - for (ActiveToolMod mod : TConstructRegistry.activeModifiers) - { - earlyModDamage = mod.baseAttackDamage(earlyModDamage, damage, tool, tags, toolTags, stack, player, entity); - } - damage += earlyModDamage; - - if (player.isPotionActive(Potion.damageBoost)) - { - damage += 3 << player.getActivePotionEffect(Potion.damageBoost).getAmplifier(); - } - - if (player.isPotionActive(Potion.weakness)) - { - damage -= 2 << player.getActivePotionEffect(Potion.weakness).getAmplifier(); - } - - float knockback = 0; - int enchantDamage = 0; - - if (entity instanceof EntityLiving) - { - enchantDamage = EnchantmentHelper.getEnchantmentModifierLiving(player, (EntityLiving) entity); - knockback += EnchantmentHelper.getKnockbackModifier(player, (EntityLiving) entity); - } - - damage += stoneboundDamage; - if (damage < 1) - damage = 1; - - if (player.isSprinting()) - { - knockback++; - float lunge = tool.chargeAttack(); - if (lunge > 1f) - { - knockback += lunge - 1.0f; - damage *= lunge; - } - } - - float modKnockback = 0f; - for (ActiveToolMod mod : TConstructRegistry.activeModifiers) - { - modKnockback = mod.knockback(modKnockback, knockback, tool, tags, toolTags, stack, player, entity); - } - knockback += modKnockback; - - int modDamage = 0; - for (ActiveToolMod mod : TConstructRegistry.activeModifiers) - { - modDamage = mod.attackDamage(modDamage, damage, tool, tags, toolTags, stack, player, entity); - } - damage += modDamage; - - if (damage > 0 || enchantDamage > 0) - { - boolean criticalHit = player.fallDistance > 0.0F && !player.onGround && !player.isOnLadder() && !player.isInWater() && !player.isPotionActive(Potion.blindness) - && player.ridingEntity == null && entity instanceof EntityLiving; - - if (tool == TContent.cutlass && random.nextInt(10) == 0) - criticalHit = true; - - if (criticalHit) - { - damage += random.nextInt(damage / 2 + 2); - } - - damage += enchantDamage; - - if (tool.getDamageModifier() != 1f) - { - damage *= tool.getDamageModifier(); - } - boolean var6 = false; - int fireAspect = EnchantmentHelper.getFireAspectModifier(player); - - if (entity instanceof EntityLiving && fireAspect > 0 && !entity.isBurning()) - { - var6 = true; - entity.setFire(1); - } - - if (broken) - damage = 1; - boolean causedDamage = false; - if (tool.pierceArmor() && !broken) - causedDamage = entity.attackEntityFrom(causePlayerPiercingDamage(player), damage); - else - causedDamage = entity.attackEntityFrom(DamageSource.causePlayerDamage(player), damage); - - if (causedDamage) - { - damageTool(stack, 1, player, false); - tool.onEntityDamaged(player.worldObj, player, entity); - int drain = toolTags.getInteger("Necrotic") * 2; - if (drain > 0) - player.heal(random.nextInt(drain+1)); - - if (knockback > 0) - { - entity.addVelocity((double) (-MathHelper.sin(player.rotationYaw * (float) Math.PI / 180.0F) * (float) knockback * 0.5F), 0.1D, - (double) (MathHelper.cos(player.rotationYaw * (float) Math.PI / 180.0F) * (float) knockback * 0.5F)); - player.motionX *= 0.6D; - player.motionZ *= 0.6D; - player.setSprinting(false); - } - - if (criticalHit) - { - player.onCriticalHit(entity); - } - - if (enchantDamage > 0) - { - player.onEnchantmentCritical(entity); - } - - if (damage >= 18) - { - player.triggerAchievement(AchievementList.overkill); - } - - player.setLastAttackingEntity(entity); - - if (entity instanceof EntityLiving) - { - EnchantmentThorns.func_92096_a(player, (EntityLiving) entity, random); - } - } - - if (entity instanceof EntityLiving) - { - stack.hitEntity((EntityLiving) entity, player); - if (entity.isEntityAlive()) - { - alertPlayerWolves(player, (EntityLiving) entity, true); - } - - player.addStat(StatList.damageDealtStat, damage); - - if ((fireAspect > 0 || toolTags.hasKey("Fiery") || toolTags.hasKey("Lava")) && causedDamage) - { - fireAspect *= 4; - if (toolTags.hasKey("Fiery")) - { - fireAspect += toolTags.getInteger("Fiery") / 5 + 1; - } - if (toolTags.getBoolean("Lava")) - { - fireAspect += 3; - } - entity.setFire(fireAspect); - } - else if (var6) - { - entity.extinguish(); - } - } - - player.addExhaustion(0.3F); - if (causedDamage) - return true; - } - } - } - return false; - } - - static void alertPlayerWolves (EntityPlayer player, EntityLiving living, boolean par2) - { - if (!(living instanceof EntityCreeper) && !(living instanceof EntityGhast)) - { - if (living instanceof EntityWolf) - { - EntityWolf var3 = (EntityWolf) living; - - if (var3.isTamed() && player.username.equals(var3.getOwnerName())) - { - return; - } - } - - if (!(living instanceof EntityPlayer) || player.func_96122_a((EntityPlayer) living)) - { - List var6 = player.worldObj.getEntitiesWithinAABB(EntityWolf.class, - AxisAlignedBB.getAABBPool().getAABB(player.posX, player.posY, player.posZ, player.posX + 1.0D, player.posY + 1.0D, player.posZ + 1.0D).expand(16.0D, 4.0D, 16.0D)); - Iterator var4 = var6.iterator(); - - while (var4.hasNext()) - { - EntityWolf var5 = (EntityWolf) var4.next(); - - if (var5.isTamed() && var5.getEntityToAttack() == null && player.username.equals(var5.getOwnerName()) && (!par2 || !var5.isSitting())) - { - var5.setSitting(false); - var5.setTarget(living); - } - } - } - } - } - - /* Tool specific */ - public static void damageTool (ItemStack stack, int dam, EntityLiving entity, boolean ignoreCharge) - { - NBTTagCompound tags = stack.getTagCompound(); - damageTool(stack, dam, tags, entity, ignoreCharge); - } - - public static void healTool (ItemStack stack, int dam, EntityLiving entity, boolean ignoreCharge) - { - NBTTagCompound tags = stack.getTagCompound(); - damageTool(stack, -dam, tags, entity, ignoreCharge); - } - - public static void damageTool (ItemStack stack, int dam, NBTTagCompound tags, EntityLiving entity, boolean ignoreCharge) - { - if (entity instanceof EntityPlayer && ((EntityPlayer) entity).capabilities.isCreativeMode || tags == null) - return; - - if (ignoreCharge || !damageElectricTool(stack, tags, entity)) - { - boolean damagedTool = false; - for (ActiveToolMod mod : TConstructRegistry.activeModifiers) - { - if (mod.damageTool(stack, dam, entity)) - damagedTool = true; - } - - if (damagedTool) - return; - - int damage = tags.getCompoundTag("InfiTool").getInteger("Damage"); - int damageTrue = damage + dam; - int maxDamage = tags.getCompoundTag("InfiTool").getInteger("TotalDurability"); - if (damageTrue <= 0) - { - tags.getCompoundTag("InfiTool").setInteger("Damage", 0); - stack.setItemDamage(0); - } - - else if (damageTrue > maxDamage) - { - breakTool(stack, tags, entity); - stack.setItemDamage(0); - } - - else - { - tags.getCompoundTag("InfiTool").setInteger("Damage", damage + dam); - int toolDamage = (damage * 100 / maxDamage) + 1; - int stackDamage = stack.getItemDamage(); - if (toolDamage != stackDamage) - { - stack.setItemDamage((damage * 100 / maxDamage) + 1); - } - } - } - } - - public static boolean damageElectricTool (ItemStack stack, NBTTagCompound tags, Entity entity) - { - if (!tags.hasKey("charge")) - return false; - - int charge = tags.getInteger("charge"); - int mineSpeed = tags.getCompoundTag("InfiTool").getInteger("MiningSpeed"); - if (tags.getCompoundTag("InfiTool").hasKey("MiningSpeed2")) - mineSpeed = (mineSpeed + tags.getCompoundTag("InfiTool").getInteger("MiningSpeed2")) / 2; - - int durability = tags.getInteger("Damage"); - float shoddy = tags.getFloat("Shoddy"); - mineSpeed += shoddy * durability / 100f; - mineSpeed /= 15; - - if (charge < mineSpeed) - { - if (charge > 0) - tags.setInteger("charge", 0); - return false; - } - /*if (entity instanceof EntityPlayer && ElectricItem.use(stack, mineSpeed, (EntityPlayer) entity)) - return true;*/ - - charge -= mineSpeed; - ToolCore tool = (ToolCore) stack.getItem(); - stack.setItemDamage(1 + (tool.getMaxCharge(stack) - charge) * (stack.getMaxDamage() - 1) / tool.getMaxCharge(stack)); - tags.setInteger("charge", charge); - if (entity instanceof EntityPlayer) - chargeFromArmor(stack, (EntityPlayer) entity); - return true; - } - - static void chargeFromArmor (ItemStack stack, EntityPlayer player) - { - boolean inContainer = false; - - for (int armorIter = 0; armorIter < 4; ++armorIter) - { - ItemStack armor = player.inventory.armorInventory[armorIter]; - - if (armor != null && armor.getItem() instanceof IElectricItem) - { - IElectricItem electricArmor = (IElectricItem) armor.getItem(); - ToolCore tool = (ToolCore) stack.getItem(); - - if (electricArmor.canProvideEnergy(stack) && electricArmor.getTier(stack) >= ((IElectricItem) stack.getItem()).getTier(stack)) - { - int chargeAmount = tool.charge(stack, Integer.MAX_VALUE, Integer.MAX_VALUE, true, true); - chargeAmount = discharge(armor, chargeAmount, Integer.MAX_VALUE, true, false); - - if (chargeAmount > 0) - { - tool.charge(stack, chargeAmount, Integer.MAX_VALUE, true, false); - inContainer = true; - } - } - } - } - - if (inContainer) - { - player.openContainer.detectAndSendChanges(); - } - } - - public static int discharge (ItemStack stack, int amount, int tier, boolean ignoreTransferLimit, boolean simulate) - { - IElectricItem ielectricitem = (IElectricItem) stack.getItem(); - - if (ielectricitem instanceof ICustomElectricItem) - { - return ((ICustomElectricItem) ielectricitem).discharge(stack, amount, tier, ignoreTransferLimit, simulate); - } - else if (amount >= 0 && stack.stackSize <= 1 && ielectricitem.getTier(stack) <= tier) - { - if (amount > ielectricitem.getTransferLimit(stack) && !ignoreTransferLimit) - { - amount = ielectricitem.getTransferLimit(stack); - } - - NBTTagCompound tags = stack.getTagCompound(); - int charge = tags.getInteger("charge"); - - if (amount > charge) - { - amount = charge; - } - - charge -= amount; - - if (!simulate) - { - tags.setInteger("charge", charge); - stack.itemID = charge > 0 ? ielectricitem.getChargedItemId(stack) : ielectricitem.getEmptyItemId(stack); - - if (stack.getItem() instanceof IElectricItem) - { - ielectricitem = (IElectricItem) stack.getItem(); - - if (stack.getMaxDamage() > 2) - { - if (stack.getItemDamage() + 1 < stack.getMaxDamage()) - stack.setItemDamage(1 + (ielectricitem.getMaxCharge(stack) - charge) * (stack.getMaxDamage() - 2) / ielectricitem.getMaxCharge(stack)); - } - else - { - stack.setItemDamage(0); - } - } - else - { - stack.setItemDamage(0); - } - } - - return amount; - } - else - { - return 0; - } - - } - - public static void breakTool (ItemStack stack, NBTTagCompound tags, Entity entity) - { - tags.getCompoundTag("InfiTool").setBoolean("Broken", true); - if (entity != null) - entity.worldObj.playSound(entity.posX, entity.posY, entity.posZ, "random.break", 1f, 1f, true); - } - - public static void repairTool (ItemStack stack, NBTTagCompound tags) - { - tags.getCompoundTag("InfiTool").setBoolean("Broken", false); - tags.getCompoundTag("InfiTool").setInteger("Damage", 0); - } - - public static DamageSource causePiercingDamage (EntityLiving mob) - { - return new PiercingEntityDamage("mob", mob); - } - - public static DamageSource causePlayerPiercingDamage (EntityPlayer player) - { - return new PiercingEntityDamage("player", player); - } - - public static void knockbackEntity (EntityLiving living, double boost) - { - living.motionX *= boost; - //living.motionY *= boost/2; - living.motionZ *= boost; - } - - public static boolean hoeGround (ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, Random random) - { - if (!player.canPlayerEdit(x, y, z, side, stack)) - { - return false; - } - else - { - UseHoeEvent event = new UseHoeEvent(player, stack, world, x, y, z); - if (MinecraftForge.EVENT_BUS.post(event)) - { - return false; - } - - if (event.getResult() == Result.ALLOW) - { - onBlockChanged(stack, world, 0, x, y, z, player, random); - return true; - } - - int bID = world.getBlockId(x, y, z); - int bIDabove = world.getBlockId(x, y + 1, z); - - if ((side == 0 || bIDabove != 0 || bID != Block.grass.blockID) && bID != Block.dirt.blockID) - { - return false; - } - else - { - Block block = Block.tilledField; - world.playSoundEffect((double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F), block.stepSound.getStepSound(), - (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F); - - if (world.isRemote) - { - return true; - } - else - { - world.setBlock(x, y, z, block.blockID); - onBlockChanged(stack, world, 0, x, y, z, player, random); - return true; - } - } - } - } - - public static void spawnItemAtPlayer (EntityPlayer player, ItemStack stack) - { - EntityItem entityitem = new EntityItem(player.worldObj, player.posX + 0.5D, player.posY + 0.5D, player.posZ + 0.5D, stack); - player.worldObj.spawnEntityInWorld(entityitem); - if (!(player instanceof FakePlayer)) - entityitem.onCollideWithPlayer(player); - /*if (!player.inventory.addItemStackToInventory(stack)) - { - if (!player.worldObj.isRemote) - { - EntityItem entityitem = new EntityItem(player.worldObj, player.posX + 0.5D, player.posY + 0.5D, player.posZ + 0.5D, stack); - player.worldObj.spawnEntityInWorld(entityitem); - entityitem.onCollideWithPlayer(player); - } - } - else - { - player.worldObj.playSoundAtEntity(player, "random.pop", 0.2F, ((random.nextFloat() - random.nextFloat()) * 0.7F + 1.0F) * 2.0F); - }*/ - } - - /* Ranged weapons */ - - public static void forceAddToInv (EntityPlayer entityplayer, ItemStack itemstack, int i, boolean flag) - { - ItemStack itemstack1 = entityplayer.inventory.getStackInSlot(i); - entityplayer.inventory.setInventorySlotContents(i, itemstack); - if (itemstack1 != null) - { - addToInv(entityplayer, itemstack1, flag); - } - } - - public static boolean addToInv (EntityPlayer entityplayer, ItemStack itemstack, boolean flag) - { - return addToInv(entityplayer, itemstack, entityplayer.inventory.currentItem, flag); - } - - public static boolean addToInv (EntityPlayer entityplayer, ItemStack itemstack, int i, boolean flag) - { - ItemStack itemstack1 = entityplayer.inventory.getStackInSlot(i); - boolean flag1; - if (itemstack1 == null) - { - entityplayer.inventory.setInventorySlotContents(i, itemstack); - flag1 = true; - } - else - { - flag1 = entityplayer.inventory.addItemStackToInventory(itemstack); - } - if (flag && !flag1) - { - addItemStackToWorld(entityplayer.worldObj, (float) Math.floor(entityplayer.posX), (float) Math.floor(entityplayer.posY), (float) Math.floor(entityplayer.posZ), itemstack); - return true; - } - else - { - return flag1; - } - } - - public static EntityItem addItemStackToWorld (World world, float f, float f1, float f2, ItemStack itemstack) - { - return addItemStackToWorld(world, f, f1, f2, itemstack, false); - } - - public static EntityItem addItemStackToWorld (World world, float f, float f1, float f2, ItemStack itemstack, boolean flag) - { - EntityItem entityitem; - if (flag) - { - entityitem = new EntityItem(world, f, f1, f2, itemstack); - } - else - { - float f3 = 0.7F; - float f4 = random.nextFloat() * f3 + (1.0F - f3) * 0.5F; - float f5 = 1.2F; - float f6 = random.nextFloat() * f3 + (1.0F - f3) * 0.5F; - entityitem = new EntityItem(world, f + f4, f1 + f5, f2 + f6, itemstack); - } - entityitem.delayBeforeCanPickup = 10; - world.spawnEntityInWorld(entityitem); - return entityitem; - } - - public static MovingObjectPosition raytraceFromEntity (World world, Entity player, boolean par3, double range) + static Random random = new Random(); + + /* Normal interactions */ + public static boolean onBlockChanged (ItemStack stack, World world, int bID, int x, int y, int z, EntityLiving player, Random random) + { + if (!stack.hasTagCompound()) + return false; + + int reinforced = 0; + NBTTagCompound tags = stack.getTagCompound(); + + if (tags.getCompoundTag("InfiTool").hasKey("Unbreaking")) + reinforced = tags.getCompoundTag("InfiTool").getInteger("Unbreaking"); + + if (random.nextInt(10) < 10 - reinforced) + { + damageTool(stack, 1, tags, player, false); + } + + return true; + } + + public static boolean onLeftClickEntity (ItemStack stack, EntityLiving player, Entity entity, ToolCore tool) + { + return onLeftClickEntity(stack, player, entity, tool, 0); + } + + public static boolean onLeftClickEntity (ItemStack stack, EntityLiving player, Entity entity, ToolCore tool, int baseDamage) + { + if (entity.canAttackWithItem() && stack.hasTagCompound()) + { + if (!entity.func_85031_j(player)) // can't attack this entity + { + NBTTagCompound tags = stack.getTagCompound(); + NBTTagCompound toolTags = stack.getTagCompound().getCompoundTag("InfiTool"); + int damage = toolTags.getInteger("Attack") + baseDamage; + boolean broken = toolTags.getBoolean("Broken"); + + int durability = tags.getCompoundTag("InfiTool").getInteger("Damage"); + float stonebound = tags.getCompoundTag("InfiTool").getFloat("Shoddy"); + + float stoneboundDamage = (float) Math.log(durability / 72f + 1) * -2 * stonebound; + + int earlyModDamage = 0; + for (ActiveToolMod mod : TConstructRegistry.activeModifiers) + { + earlyModDamage = mod.baseAttackDamage(earlyModDamage, damage, tool, tags, toolTags, stack, player, entity); + } + damage += earlyModDamage; + + if (player.isPotionActive(Potion.damageBoost)) + { + damage += 3 << player.getActivePotionEffect(Potion.damageBoost).getAmplifier(); + } + + if (player.isPotionActive(Potion.weakness)) + { + damage -= 2 << player.getActivePotionEffect(Potion.weakness).getAmplifier(); + } + + float knockback = 0; + int enchantDamage = 0; + + if (entity instanceof EntityLiving) + { + enchantDamage = EnchantmentHelper.getEnchantmentModifierLiving(player, (EntityLiving) entity); + knockback += EnchantmentHelper.getKnockbackModifier(player, (EntityLiving) entity); + } + + damage += stoneboundDamage; + if (damage < 1) + damage = 1; + + if (player.isSprinting()) + { + knockback++; + float lunge = tool.chargeAttack(); + if (lunge > 1f) + { + knockback += lunge - 1.0f; + damage *= lunge; + } + } + + float modKnockback = 0f; + for (ActiveToolMod mod : TConstructRegistry.activeModifiers) + { + modKnockback = mod.knockback(modKnockback, knockback, tool, tags, toolTags, stack, player, entity); + } + knockback += modKnockback; + + int modDamage = 0; + for (ActiveToolMod mod : TConstructRegistry.activeModifiers) + { + modDamage = mod.attackDamage(modDamage, damage, tool, tags, toolTags, stack, player, entity); + } + damage += modDamage; + + if (damage > 0 || enchantDamage > 0) + { + boolean criticalHit = player.fallDistance > 0.0F && !player.onGround && !player.isOnLadder() && !player.isInWater() && !player.isPotionActive(Potion.blindness) + && player.ridingEntity == null && entity instanceof EntityLiving; + + if (tool == TContent.cutlass && random.nextInt(10) == 0) + criticalHit = true; + + if (criticalHit) + { + damage += random.nextInt(damage / 2 + 2); + } + + damage += enchantDamage; + + if (tool.getDamageModifier() != 1f) + { + damage *= tool.getDamageModifier(); + } + boolean var6 = false; + int fireAspect = EnchantmentHelper.getFireAspectModifier(player); + + if (entity instanceof EntityLiving && fireAspect > 0 && !entity.isBurning()) + { + var6 = true; + entity.setFire(1); + } + + if (broken) + { + if (baseDamage > 0) + damage = baseDamage; + else + damage = 1; + } + boolean causedDamage = false; + if (tool.pierceArmor() && !broken) + { + if (player instanceof EntityPlayer) + causedDamage = entity.attackEntityFrom(causePlayerPiercingDamage((EntityPlayer) player), damage); + else + causedDamage = entity.attackEntityFrom(causePiercingDamage(player), damage); + } + else + { + if (player instanceof EntityPlayer) + causedDamage = entity.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) player), damage); + else + causedDamage = entity.attackEntityFrom(DamageSource.causeMobDamage(player), damage); + } + + if (causedDamage) + { + damageTool(stack, 1, player, false); + tool.onEntityDamaged(player.worldObj, player, entity); + int drain = toolTags.getInteger("Necrotic") * 2; + if (drain > 0) + player.heal(random.nextInt(drain + 1)); + + if (knockback > 0) + { + entity.addVelocity((double) (-MathHelper.sin(player.rotationYaw * (float) Math.PI / 180.0F) * (float) knockback * 0.5F), 0.1D, + (double) (MathHelper.cos(player.rotationYaw * (float) Math.PI / 180.0F) * (float) knockback * 0.5F)); + player.motionX *= 0.6D; + player.motionZ *= 0.6D; + player.setSprinting(false); + } + + if (player instanceof EntityPlayer) + { + if (criticalHit) + { + ((EntityPlayer) player).onCriticalHit(entity); + } + + if (enchantDamage > 0) + { + ((EntityPlayer) player).onEnchantmentCritical(entity); + } + + if (damage >= 18) + { + ((EntityPlayer) player).triggerAchievement(AchievementList.overkill); + } + } + + player.setLastAttackingEntity(entity); + + if (entity instanceof EntityLiving) + { + EnchantmentThorns.func_92096_a(player, (EntityLiving) entity, random); + } + } + + if (entity instanceof EntityLiving) + { + if (entity instanceof EntityPlayer) + { + stack.hitEntity((EntityLiving) entity, (EntityPlayer) player); + if (entity.isEntityAlive()) + { + alertPlayerWolves((EntityPlayer) player, (EntityLiving) entity, true); + } + + ((EntityPlayer) player).addStat(StatList.damageDealtStat, damage); + } + else + { + Item.itemsList[stack.itemID].hitEntity(stack, (EntityLiving) entity, player); + } + + if ((fireAspect > 0 || toolTags.hasKey("Fiery") || toolTags.hasKey("Lava")) && causedDamage) + { + fireAspect *= 4; + if (toolTags.hasKey("Fiery")) + { + fireAspect += toolTags.getInteger("Fiery") / 5 + 1; + } + if (toolTags.getBoolean("Lava")) + { + fireAspect += 3; + } + entity.setFire(fireAspect); + } + else if (var6) + { + entity.extinguish(); + } + } + + if (entity instanceof EntityPlayer) + ((EntityPlayer) player).addExhaustion(0.3F); + if (causedDamage) + return true; + } + } + } + return false; + } + + static void alertPlayerWolves (EntityPlayer player, EntityLiving living, boolean par2) + { + if (!(living instanceof EntityCreeper) && !(living instanceof EntityGhast)) + { + if (living instanceof EntityWolf) + { + EntityWolf var3 = (EntityWolf) living; + + if (var3.isTamed() && player.username.equals(var3.getOwnerName())) + { + return; + } + } + + if (!(living instanceof EntityPlayer) || player.func_96122_a((EntityPlayer) living)) + { + List var6 = player.worldObj.getEntitiesWithinAABB(EntityWolf.class, + AxisAlignedBB.getAABBPool().getAABB(player.posX, player.posY, player.posZ, player.posX + 1.0D, player.posY + 1.0D, player.posZ + 1.0D).expand(16.0D, 4.0D, 16.0D)); + Iterator var4 = var6.iterator(); + + while (var4.hasNext()) + { + EntityWolf var5 = (EntityWolf) var4.next(); + + if (var5.isTamed() && var5.getEntityToAttack() == null && player.username.equals(var5.getOwnerName()) && (!par2 || !var5.isSitting())) + { + var5.setSitting(false); + var5.setTarget(living); + } + } + } + } + } + + /* Tool specific */ + public static void damageTool (ItemStack stack, int dam, EntityLiving entity, boolean ignoreCharge) + { + NBTTagCompound tags = stack.getTagCompound(); + damageTool(stack, dam, tags, entity, ignoreCharge); + } + + public static void healTool (ItemStack stack, int dam, EntityLiving entity, boolean ignoreCharge) + { + NBTTagCompound tags = stack.getTagCompound(); + damageTool(stack, -dam, tags, entity, ignoreCharge); + } + + public static void damageTool (ItemStack stack, int dam, NBTTagCompound tags, EntityLiving entity, boolean ignoreCharge) + { + if (entity instanceof EntityPlayer && ((EntityPlayer) entity).capabilities.isCreativeMode || tags == null) + return; + + if (ignoreCharge || !damageElectricTool(stack, tags, entity)) + { + boolean damagedTool = false; + for (ActiveToolMod mod : TConstructRegistry.activeModifiers) + { + if (mod.damageTool(stack, dam, entity)) + damagedTool = true; + } + + if (damagedTool) + return; + + int damage = tags.getCompoundTag("InfiTool").getInteger("Damage"); + int damageTrue = damage + dam; + int maxDamage = tags.getCompoundTag("InfiTool").getInteger("TotalDurability"); + if (damageTrue <= 0) + { + tags.getCompoundTag("InfiTool").setInteger("Damage", 0); + stack.setItemDamage(0); + } + + else if (damageTrue > maxDamage) + { + breakTool(stack, tags, entity); + stack.setItemDamage(0); + } + + else + { + tags.getCompoundTag("InfiTool").setInteger("Damage", damage + dam); + int toolDamage = (damage * 100 / maxDamage) + 1; + int stackDamage = stack.getItemDamage(); + if (toolDamage != stackDamage) + { + stack.setItemDamage((damage * 100 / maxDamage) + 1); + } + } + } + } + + public static boolean damageElectricTool (ItemStack stack, NBTTagCompound tags, Entity entity) + { + if (!tags.hasKey("charge")) + return false; + + int charge = tags.getInteger("charge"); + int mineSpeed = tags.getCompoundTag("InfiTool").getInteger("MiningSpeed"); + if (tags.getCompoundTag("InfiTool").hasKey("MiningSpeed2")) + mineSpeed = (mineSpeed + tags.getCompoundTag("InfiTool").getInteger("MiningSpeed2")) / 2; + + int durability = tags.getInteger("Damage"); + float shoddy = tags.getFloat("Shoddy"); + mineSpeed += shoddy * durability / 100f; + mineSpeed /= 15; + + if (charge < mineSpeed) + { + if (charge > 0) + tags.setInteger("charge", 0); + return false; + } + /*if (entity instanceof EntityPlayer && ElectricItem.use(stack, mineSpeed, (EntityPlayer) entity)) + return true;*/ + + charge -= mineSpeed; + ToolCore tool = (ToolCore) stack.getItem(); + stack.setItemDamage(1 + (tool.getMaxCharge(stack) - charge) * (stack.getMaxDamage() - 1) / tool.getMaxCharge(stack)); + tags.setInteger("charge", charge); + if (entity instanceof EntityPlayer) + chargeFromArmor(stack, (EntityPlayer) entity); + return true; + } + + static void chargeFromArmor (ItemStack stack, EntityPlayer player) + { + boolean inContainer = false; + + for (int armorIter = 0; armorIter < 4; ++armorIter) + { + ItemStack armor = player.inventory.armorInventory[armorIter]; + + if (armor != null && armor.getItem() instanceof IElectricItem) + { + IElectricItem electricArmor = (IElectricItem) armor.getItem(); + ToolCore tool = (ToolCore) stack.getItem(); + + if (electricArmor.canProvideEnergy(stack) && electricArmor.getTier(stack) >= ((IElectricItem) stack.getItem()).getTier(stack)) + { + int chargeAmount = tool.charge(stack, Integer.MAX_VALUE, Integer.MAX_VALUE, true, true); + chargeAmount = discharge(armor, chargeAmount, Integer.MAX_VALUE, true, false); + + if (chargeAmount > 0) + { + tool.charge(stack, chargeAmount, Integer.MAX_VALUE, true, false); + inContainer = true; + } + } + } + } + + if (inContainer) + { + player.openContainer.detectAndSendChanges(); + } + } + + public static int discharge (ItemStack stack, int amount, int tier, boolean ignoreTransferLimit, boolean simulate) + { + IElectricItem ielectricitem = (IElectricItem) stack.getItem(); + + if (ielectricitem instanceof ICustomElectricItem) + { + return ((ICustomElectricItem) ielectricitem).discharge(stack, amount, tier, ignoreTransferLimit, simulate); + } + else if (amount >= 0 && stack.stackSize <= 1 && ielectricitem.getTier(stack) <= tier) + { + if (amount > ielectricitem.getTransferLimit(stack) && !ignoreTransferLimit) + { + amount = ielectricitem.getTransferLimit(stack); + } + + NBTTagCompound tags = stack.getTagCompound(); + int charge = tags.getInteger("charge"); + + if (amount > charge) + { + amount = charge; + } + + charge -= amount; + + if (!simulate) + { + tags.setInteger("charge", charge); + stack.itemID = charge > 0 ? ielectricitem.getChargedItemId(stack) : ielectricitem.getEmptyItemId(stack); + + if (stack.getItem() instanceof IElectricItem) + { + ielectricitem = (IElectricItem) stack.getItem(); + + if (stack.getMaxDamage() > 2) + { + if (stack.getItemDamage() + 1 < stack.getMaxDamage()) + stack.setItemDamage(1 + (ielectricitem.getMaxCharge(stack) - charge) * (stack.getMaxDamage() - 2) / ielectricitem.getMaxCharge(stack)); + } + else + { + stack.setItemDamage(0); + } + } + else + { + stack.setItemDamage(0); + } + } + + return amount; + } + else + { + return 0; + } + + } + + public static void breakTool (ItemStack stack, NBTTagCompound tags, Entity entity) + { + tags.getCompoundTag("InfiTool").setBoolean("Broken", true); + if (entity != null) + entity.worldObj.playSound(entity.posX, entity.posY, entity.posZ, "random.break", 1f, 1f, true); + } + + public static void repairTool (ItemStack stack, NBTTagCompound tags) + { + tags.getCompoundTag("InfiTool").setBoolean("Broken", false); + tags.getCompoundTag("InfiTool").setInteger("Damage", 0); + } + + public static DamageSource causePiercingDamage (EntityLiving mob) + { + return new PiercingEntityDamage("mob", mob); + } + + public static DamageSource causePlayerPiercingDamage (EntityPlayer player) + { + return new PiercingEntityDamage("player", player); + } + + public static void knockbackEntity (EntityLiving living, double boost) + { + living.motionX *= boost; + //living.motionY *= boost/2; + living.motionZ *= boost; + } + + public static boolean hoeGround (ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, Random random) + { + if (!player.canPlayerEdit(x, y, z, side, stack)) + { + return false; + } + else + { + UseHoeEvent event = new UseHoeEvent(player, stack, world, x, y, z); + if (MinecraftForge.EVENT_BUS.post(event)) + { + return false; + } + + if (event.getResult() == Result.ALLOW) + { + onBlockChanged(stack, world, 0, x, y, z, player, random); + return true; + } + + int bID = world.getBlockId(x, y, z); + int bIDabove = world.getBlockId(x, y + 1, z); + + if ((side == 0 || bIDabove != 0 || bID != Block.grass.blockID) && bID != Block.dirt.blockID) + { + return false; + } + else + { + Block block = Block.tilledField; + world.playSoundEffect((double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F), block.stepSound.getStepSound(), + (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F); + + if (world.isRemote) + { + return true; + } + else + { + world.setBlock(x, y, z, block.blockID); + onBlockChanged(stack, world, 0, x, y, z, player, random); + return true; + } + } + } + } + + public static void spawnItemAtPlayer (EntityPlayer player, ItemStack stack) + { + EntityItem entityitem = new EntityItem(player.worldObj, player.posX + 0.5D, player.posY + 0.5D, player.posZ + 0.5D, stack); + player.worldObj.spawnEntityInWorld(entityitem); + if (!(player instanceof FakePlayer)) + entityitem.onCollideWithPlayer(player); + /*if (!player.inventory.addItemStackToInventory(stack)) + { + if (!player.worldObj.isRemote) + { + EntityItem entityitem = new EntityItem(player.worldObj, player.posX + 0.5D, player.posY + 0.5D, player.posZ + 0.5D, stack); + player.worldObj.spawnEntityInWorld(entityitem); + entityitem.onCollideWithPlayer(player); + } + } + else + { + player.worldObj.playSoundAtEntity(player, "random.pop", 0.2F, ((random.nextFloat() - random.nextFloat()) * 0.7F + 1.0F) * 2.0F); + }*/ + } + + /* Ranged weapons */ + + public static void forceAddToInv (EntityPlayer entityplayer, ItemStack itemstack, int i, boolean flag) + { + ItemStack itemstack1 = entityplayer.inventory.getStackInSlot(i); + entityplayer.inventory.setInventorySlotContents(i, itemstack); + if (itemstack1 != null) + { + addToInv(entityplayer, itemstack1, flag); + } + } + + public static boolean addToInv (EntityPlayer entityplayer, ItemStack itemstack, boolean flag) + { + return addToInv(entityplayer, itemstack, entityplayer.inventory.currentItem, flag); + } + + public static boolean addToInv (EntityPlayer entityplayer, ItemStack itemstack, int i, boolean flag) + { + ItemStack itemstack1 = entityplayer.inventory.getStackInSlot(i); + boolean flag1; + if (itemstack1 == null) + { + entityplayer.inventory.setInventorySlotContents(i, itemstack); + flag1 = true; + } + else + { + flag1 = entityplayer.inventory.addItemStackToInventory(itemstack); + } + if (flag && !flag1) + { + addItemStackToWorld(entityplayer.worldObj, (float) Math.floor(entityplayer.posX), (float) Math.floor(entityplayer.posY), (float) Math.floor(entityplayer.posZ), itemstack); + return true; + } + else + { + return flag1; + } + } + + public static EntityItem addItemStackToWorld (World world, float f, float f1, float f2, ItemStack itemstack) + { + return addItemStackToWorld(world, f, f1, f2, itemstack, false); + } + + public static EntityItem addItemStackToWorld (World world, float f, float f1, float f2, ItemStack itemstack, boolean flag) + { + EntityItem entityitem; + if (flag) + { + entityitem = new EntityItem(world, f, f1, f2, itemstack); + } + else + { + float f3 = 0.7F; + float f4 = random.nextFloat() * f3 + (1.0F - f3) * 0.5F; + float f5 = 1.2F; + float f6 = random.nextFloat() * f3 + (1.0F - f3) * 0.5F; + entityitem = new EntityItem(world, f + f4, f1 + f5, f2 + f6, itemstack); + } + entityitem.delayBeforeCanPickup = 10; + world.spawnEntityInWorld(entityitem); + return entityitem; + } + + public static MovingObjectPosition raytraceFromEntity (World world, Entity player, boolean par3, double range) { float f = 1.0F; float f1 = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * f; diff --git a/mods/tinker/tconstruct/library/tools/ToolCore.java b/mods/tinker/tconstruct/library/tools/ToolCore.java index a1b1e0f..ddd29f4 100644 --- a/mods/tinker/tconstruct/library/tools/ToolCore.java +++ b/mods/tinker/tconstruct/library/tools/ToolCore.java @@ -501,7 +501,7 @@ public abstract class ToolCore extends Item implements ICustomElectricItem, IBox } //Used for sounds and the like - public void onEntityDamaged (World world, EntityPlayer player, Entity entity) + public void onEntityDamaged (World world, EntityLiving player, Entity entity) { } @@ -594,7 +594,7 @@ public abstract class ToolCore extends Item implements ICustomElectricItem, IBox @Override public boolean onLeftClickEntity (ItemStack stack, EntityPlayer player, Entity entity) { - AbilityHelper.onLeftClickEntity(stack, player, entity, this); + AbilityHelper.onLeftClickEntity(stack, player, entity, this, 0); return true; } @@ -877,56 +877,11 @@ public abstract class ToolCore extends Item implements ICustomElectricItem, IBox } /* Proper stack damage */ - public int getItemDamageFromStack (ItemStack stack) - { - if (stack.itemDamage == Short.MAX_VALUE ) - return Short.MAX_VALUE; - NBTTagCompound tags = stack.getTagCompound(); - if (tags == null) - { - //System.out.println("Tool item is uninitalized! This method should never be called with a default item"); - //Exception e = new NullPointerException(); - //e.printStackTrace(); - return 0; - } - - if (tags.hasKey("charge")) - { - int charge = tags.getInteger("charge"); - if (charge > 0) - return getMaxCharge(stack) - charge; - } - return tags.getCompoundTag("InfiTool").getInteger("Damage"); - } - - public int getItemDamageFromStackForDisplay (ItemStack stack) - { - NBTTagCompound tags = stack.getTagCompound(); - if (tags == null) - { - //System.out.println("Tool item is uninitalized! This method should never be called with a default item"); - //Exception e = new NullPointerException(); - //e.printStackTrace(); - return 0; - } - - if (tags.hasKey("charge")) - { - int charge = tags.getInteger("charge"); - if (charge > 0) - return getMaxCharge(stack) - charge; - } - return tags.getCompoundTag("InfiTool").getInteger("Damage"); - } - public int getItemMaxDamageFromStack (ItemStack stack) { NBTTagCompound tags = stack.getTagCompound(); if (tags == null) { - //System.out.println("Tool item is uninitalized! This method should never be called with a default item"); - //Exception e = new NullPointerException(); - //e.printStackTrace(); return 0; } @@ -938,5 +893,22 @@ public abstract class ToolCore extends Item implements ICustomElectricItem, IBox } return tags.getCompoundTag("InfiTool").getInteger("TotalDurability"); } + + public int getItemDamageFromStackForDisplay (ItemStack stack) + { + NBTTagCompound tags = stack.getTagCompound(); + if (tags == null) + { + return 0; + } + + if (tags.hasKey("charge")) + { + int charge = tags.getInteger("charge"); + if (charge > 0) + return getMaxCharge(stack) - charge; + } + return tags.getCompoundTag("InfiTool").getInteger("Damage"); + } } diff --git a/mods/tinker/tconstruct/library/util/ChunkCoordTuple.java b/mods/tinker/tconstruct/library/util/ChunkCoordTuple.java new file mode 100644 index 0000000..ef5161d --- /dev/null +++ b/mods/tinker/tconstruct/library/util/ChunkCoordTuple.java @@ -0,0 +1,51 @@ +package mods.tinker.tconstruct.library.util; + +public class ChunkCoordTuple +{ + public final int x; + public final int z; + + public ChunkCoordTuple(int posX, int posZ) + { + x = posX; + z = posZ; + } + + public boolean equalCoords (int posX, int posZ) + { + if (this.x == posX && this.z == posZ) + return true; + else + return false; + } + + @Override + public boolean equals(Object obj) + { + if (obj == null) + return false; + + if(getClass() == obj.getClass()) + { + ChunkCoordTuple coord = (ChunkCoordTuple)obj; + if(this.x == coord.x && this.z == coord.z) + return true; + } + return false; + } + + @Override + public int hashCode () + { + final int prime = 37; + int result = 1; + result = prime * result + x; + result = prime * result + z; + return result; + } + + public String toString () + { + return "ChunkX: " + x + ", ChunkZ: " + z; + } +} diff --git a/mods/tinker/tconstruct/modifiers/TActiveOmniMod.java b/mods/tinker/tconstruct/modifiers/TActiveOmniMod.java index 969a7a5..27e778e 100644 --- a/mods/tinker/tconstruct/modifiers/TActiveOmniMod.java +++ b/mods/tinker/tconstruct/modifiers/TActiveOmniMod.java @@ -149,7 +149,7 @@ public class TActiveOmniMod extends ActiveToolMod /* Attacking */ @Override - public int baseAttackDamage (int earlyModDamage, int damage, ToolCore tool, NBTTagCompound tags, NBTTagCompound toolTags, ItemStack stack, EntityPlayer player, Entity entity) + public int baseAttackDamage (int earlyModDamage, int damage, ToolCore tool, NBTTagCompound tags, NBTTagCompound toolTags, ItemStack stack, EntityLiving player, Entity entity) { if (tool instanceof Weapon) TContent.modL.midStreamModify(stack); @@ -157,7 +157,7 @@ public class TActiveOmniMod extends ActiveToolMod } @Override - public int attackDamage (int modDamage, int currentDamage, ToolCore tool, NBTTagCompound tags, NBTTagCompound toolTags, ItemStack stack, EntityPlayer player, Entity entity) + public int attackDamage (int modDamage, int currentDamage, ToolCore tool, NBTTagCompound tags, NBTTagCompound toolTags, ItemStack stack, EntityLiving player, Entity entity) { int bonus = 0; if (entity instanceof EntityLiving) @@ -191,7 +191,7 @@ public class TActiveOmniMod extends ActiveToolMod } @Override - public float knockback (float modKnockback, float currentKnockback, ToolCore tool, NBTTagCompound tags, NBTTagCompound toolTags, ItemStack stack, EntityPlayer player, Entity entity) + public float knockback (float modKnockback, float currentKnockback, ToolCore tool, NBTTagCompound tags, NBTTagCompound toolTags, ItemStack stack, EntityLiving player, Entity entity) { float bonus = 0f; if (toolTags.hasKey("Knockback")) diff --git a/mods/tinker/tconstruct/util/PHConstruct.java b/mods/tinker/tconstruct/util/PHConstruct.java index 6462e09..117ecbc 100644 --- a/mods/tinker/tconstruct/util/PHConstruct.java +++ b/mods/tinker/tconstruct/util/PHConstruct.java @@ -172,6 +172,7 @@ public class PHConstruct heavyBoots = config.getItem("Equipables", "Heavy Boots", 14110).getInt(14110); glove = config.getItem("Equipables", "Gloves", 14111).getInt(14111); knapsack = config.getItem("Equipables", "Knapsack", 14112).getInt(14112); + goldHead = config.getItem("Patterns and Misc", "Golden Head", 14113).getInt(14113); boolean ic2 = true; boolean xycraft = true; @@ -252,9 +253,26 @@ public class PHConstruct aluminumBushMaxY = config.get("Worldgen", "Aluminum Bush Max Y", 60).getInt(60); seaLevel = config.get("general", "Sea level", 64).getInt(64); + + enableHealthRegen = config.get("Ultra Hardcore Changes", "Passive Health Regen", true).getBoolean(true); //Check + goldAppleRecipe = config.get("Ultra Hardcore Changes", "Change Crafting Recipes", false).getBoolean(false); //Check + dropPlayerHeads = config.get("Ultra Hardcore Changes", "Players drop heads on death", false).getBoolean(false); //Check + uhcGhastDrops = config.get("Ultra Hardcore Changes", "Change Ghast drops to Gold Ingots", false).getBoolean(false); //Check + worldBorder = config.get("Ultra Hardcore Changes", "Add World Border", false).getBoolean(false); + worldBorderSize = config.get("Ultra Hardcore Changes", "World Border Radius", 1000).getInt(1000); + freePatterns = config.get("Ultra Hardcore Changes", "Add Patterns to Pattern Chests", false).getBoolean(false); //Check /* Save the configuration file */ config.save(); + + File gt = new File(TConstruct.proxy.getLocation() + "/config/GregTech"); + if (gt.exists()) + { + File gtDyn = new File(TConstruct.proxy.getLocation() + "/config/GregTech/DynamicConfig.cfg"); + Configuration gtConfig = new Configuration(gtDyn); + gtConfig.load(); + gregtech = gtConfig.get("smelting", "tile.anvil.slightlyDamaged", false).getBoolean(false); + } } //Blocks @@ -472,7 +490,19 @@ public class PHConstruct public static boolean craftMetalTools; public static boolean vanillaMetalBlocks; + //Ultra Hardcore modifiers + public static boolean enableHealthRegen; + public static boolean goldAppleRecipe; + public static boolean dropPlayerHeads; + public static boolean uhcGhastDrops; + public static boolean worldBorder; + public static int worldBorderSize; + public static boolean freePatterns; + public static int goldHead; + //Superfun public static boolean superfunWorld; public static boolean beginnerBook; + + public static boolean gregtech; } \ No newline at end of file diff --git a/mods/tinker/tconstruct/util/RecipeRemover.java b/mods/tinker/tconstruct/util/RecipeRemover.java index de01c98..4446285 100644 --- a/mods/tinker/tconstruct/util/RecipeRemover.java +++ b/mods/tinker/tconstruct/util/RecipeRemover.java @@ -6,6 +6,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.ShapedRecipes; +import net.minecraft.item.crafting.ShapelessRecipes; public class RecipeRemover { @@ -33,4 +34,23 @@ public class RecipeRemover } } } + + public static void removeShapelessRecipe (ItemStack resultItem) + { + List recipes = CraftingManager.getInstance().getRecipeList(); + for (int i = 0; i < recipes.size(); i++) + { + IRecipe tmpRecipe = recipes.get(i); + if (tmpRecipe instanceof ShapelessRecipes) + { + ShapelessRecipes recipe = (ShapelessRecipes) tmpRecipe; + ItemStack recipeResult = recipe.getRecipeOutput(); + + if (ItemStack.areItemStacksEqual(resultItem, recipeResult)) + { + recipes.remove(i--); + } + } + } + } } diff --git a/mods/tinker/tconstruct/util/TEventHandler.java b/mods/tinker/tconstruct/util/TEventHandler.java index a54e57f..71d9583 100644 --- a/mods/tinker/tconstruct/util/TEventHandler.java +++ b/mods/tinker/tconstruct/util/TEventHandler.java @@ -1,16 +1,19 @@ package mods.tinker.tconstruct.util; import java.util.ArrayList; +import java.util.HashMap; import java.util.Random; import mods.tinker.tconstruct.TConstruct; import mods.tinker.tconstruct.blocks.logic.LiquidTextureLogic; import mods.tinker.tconstruct.common.TContent; +import mods.tinker.tconstruct.crystal.TheftValueTracker; import mods.tinker.tconstruct.library.crafting.PatternBuilder; import mods.tinker.tconstruct.library.crafting.Smeltery; import mods.tinker.tconstruct.library.crafting.ToolBuilder; import mods.tinker.tconstruct.library.event.ToolCraftEvent; import mods.tinker.tconstruct.library.tools.ToolCore; +import mods.tinker.tconstruct.library.util.ChunkCoordTuple; import mods.tinker.tconstruct.modifiers.ModAttack; import mods.tinker.tconstruct.util.player.TPlayerStats; import net.minecraft.entity.Entity; @@ -36,6 +39,8 @@ import net.minecraftforge.event.ForgeSubscribe; import net.minecraftforge.event.entity.living.LivingDropsEvent; import net.minecraftforge.event.entity.living.LivingSpawnEvent; import net.minecraftforge.event.entity.player.FillBucketEvent; +import net.minecraftforge.event.world.ChunkDataEvent; +import net.minecraftforge.event.world.ChunkEvent; import net.minecraftforge.liquids.LiquidStack; import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.OreDictionary.OreRegisterEvent; @@ -48,11 +53,6 @@ public class TEventHandler @ForgeSubscribe public void craftTool (ToolCraftEvent event) { - /*if (event.tool == TContent.hammer) - { - event.toolTag.setIntArray("Smite", new int[] { 20, 20, 1}); - }*/ - /*if (event.tool == TContent.cleaver) { event.toolTag.getCompoundTag("InfiTool").setInteger("Beheading", 2); @@ -75,25 +75,26 @@ public class TEventHandler } }*/ + /* Damage */ /*@ForgeSubscribe public void onHurt (LivingHurtEvent event) {*/ - /*if (event.entityLiving instanceof EntityPlayer) + /*if (event.entityLiving instanceof EntityPlayer) + { + EntityPlayer player = (EntityPlayer) event.entityLiving; + ItemStack stack = player.getItemInUse(); + if (stack != null && stack.getItem() == TContent.cutlass) { - EntityPlayer player = (EntityPlayer) event.entityLiving; - ItemStack stack = player.getItemInUse(); - if (stack != null && stack.getItem() == TContent.cutlass) - { - player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 3*20, 1)); - } - }*/ - /*if (event.source instanceof EntityDamageSource && event.source.damageType.equals("explosion.player") && ((EntityDamageSource) event.source).getEntity() instanceof NitroCreeper) - { - if (event.entityLiving.worldObj.difficultySetting == 3) - event.ammount /= 2.3; - else - event.ammount /= 1.5; - }*/ + player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 3*20, 1)); + } + }*/ + /*if (event.source instanceof EntityDamageSource && event.source.damageType.equals("explosion.player") && ((EntityDamageSource) event.source).getEntity() instanceof NitroCreeper) + { + if (event.entityLiving.worldObj.difficultySetting == 3) + event.ammount /= 2.3; + else + event.ammount /= 1.5; + }*/ //} /* Drops */ @@ -118,115 +119,136 @@ public class TEventHandler //if (event.entityLiving.worldObj.getGameRules().getGameRuleBooleanValue("doMobLoot")) //{ - if (!event.entityLiving.isChild()) + if (!event.entityLiving.isChild()) + { + if (event.entityLiving.getClass() == EntityCow.class) { - if (event.entityLiving.getClass() == EntityCow.class) + int amount = random.nextInt(3) + random.nextInt(1 + event.lootingLevel) + random.nextInt(3) + random.nextInt(1 + event.lootingLevel) + 1; + + for (int iter = 0; iter < amount; ++iter) { - int amount = random.nextInt(3) + random.nextInt(1 + event.lootingLevel) + random.nextInt(3) + random.nextInt(1 + event.lootingLevel) + 1; - - for (int iter = 0; iter < amount; ++iter) - { - addDrops(event, new ItemStack(Item.leather, 1)); - } - } - - else if (event.entityLiving.getClass() == EntityChicken.class) - { - int amount = random.nextInt(3) + random.nextInt(1 + event.lootingLevel) + random.nextInt(3) + random.nextInt(1 + event.lootingLevel) + 1; - - for (int iter = 0; iter < amount; ++iter) - { - addDrops(event, new ItemStack(Item.feather, 1)); - } + addDrops(event, new ItemStack(Item.leather, 1)); } } - if (event.recentlyHit) + else if (event.entityLiving.getClass() == EntityChicken.class) { - if (event.entityLiving.getClass() == EntitySkeleton.class) - { - EntitySkeleton enemy = (EntitySkeleton) event.entityLiving; + int amount = random.nextInt(3) + random.nextInt(1 + event.lootingLevel) + random.nextInt(3) + random.nextInt(1 + event.lootingLevel) + 1; - if (event.source.damageType.equals("player")) + for (int iter = 0; iter < amount; ++iter) + { + addDrops(event, new ItemStack(Item.feather, 1)); + } + } + } + + if (event.recentlyHit) + { + if (event.entityLiving.getClass() == EntitySkeleton.class) + { + EntitySkeleton enemy = (EntitySkeleton) event.entityLiving; + + if (event.source.damageType.equals("player")) + { + EntityPlayer player = (EntityPlayer) event.source.getEntity(); + ItemStack stack = player.getCurrentEquippedItem(); + if (stack != null && stack.hasTagCompound() && stack.getItem() instanceof ToolCore) { - EntityPlayer player = (EntityPlayer) event.source.getEntity(); - ItemStack stack = player.getCurrentEquippedItem(); - if (stack != null && stack.hasTagCompound() && stack.getItem() instanceof ToolCore) + int beheading = stack.getTagCompound().getCompoundTag("InfiTool").getInteger("Beheading"); + if (stack.getItem() == TContent.cleaver) + beheading += 2; + if (beheading > 0 && random.nextInt(100) < beheading * 10) { - int beheading = stack.getTagCompound().getCompoundTag("InfiTool").getInteger("Beheading"); - if (stack.getItem() == TContent.cleaver) - beheading += 2; - if (beheading > 0 && random.nextInt(100) < beheading * 10) - { - addDrops(event, new ItemStack(Item.skull.itemID, 1, enemy.getSkeletonType())); - } + addDrops(event, new ItemStack(Item.skull.itemID, 1, enemy.getSkeletonType())); } } - if (enemy.getSkeletonType() == 1 && random.nextInt(Math.max(1, 5 - event.lootingLevel)) == 0) - { - addDrops(event, new ItemStack(TContent.materials, 1, 8)); - } } - - if (event.entityLiving.getClass() == EntityZombie.class) + if (enemy.getSkeletonType() == 1 && random.nextInt(Math.max(1, 5 - event.lootingLevel)) == 0) { - EntityZombie enemy = (EntityZombie) event.entityLiving; + addDrops(event, new ItemStack(TContent.materials, 1, 8)); + } + } - if (event.source.damageType.equals("player")) + if (event.entityLiving.getClass() == EntityZombie.class) + { + EntityZombie enemy = (EntityZombie) event.entityLiving; + + if (event.source.damageType.equals("player")) + { + EntityPlayer player = (EntityPlayer) event.source.getEntity(); + ItemStack stack = player.getCurrentEquippedItem(); + + if (stack != null && stack.hasTagCompound() && stack.getItem() instanceof ToolCore) { - EntityPlayer player = (EntityPlayer) event.source.getEntity(); - ItemStack stack = player.getCurrentEquippedItem(); - - if (stack != null && stack.hasTagCompound() && stack.getItem() instanceof ToolCore) - { - int beheading = stack.getTagCompound().getCompoundTag("InfiTool").getInteger("Beheading"); - if (stack.getItem() == TContent.cleaver) - beheading += 2; - if (beheading > 0 && random.nextInt(100) < beheading * 10) - { - addDrops(event, new ItemStack(Item.skull.itemID, 1, 2)); - } - } - /*if (stack.getItem() == TContent.breakerBlade && random.nextInt(100) < 10) //Swap out for real beheading + int beheading = stack.getTagCompound().getCompoundTag("InfiTool").getInteger("Beheading"); + if (stack.getItem() == TContent.cleaver) + beheading += 2; + if (beheading > 0 && random.nextInt(100) < beheading * 10) { addDrops(event, new ItemStack(Item.skull.itemID, 1, 2)); - }*/ + } } - } - - if (event.entityLiving.getClass() == EntityCreeper.class) - { - EntityCreeper enemy = (EntityCreeper) event.entityLiving; - - if (event.source.damageType.equals("player")) + /*if (stack.getItem() == TContent.breakerBlade && random.nextInt(100) < 10) //Swap out for real beheading { - EntityPlayer player = (EntityPlayer) event.source.getEntity(); - ItemStack stack = player.getCurrentEquippedItem(); - if (stack != null && stack.hasTagCompound() && stack.getItem() instanceof ToolCore) + addDrops(event, new ItemStack(Item.skull.itemID, 1, 2)); + }*/ + } + } + + if (event.entityLiving.getClass() == EntityCreeper.class) + { + EntityCreeper enemy = (EntityCreeper) event.entityLiving; + + if (event.source.damageType.equals("player")) + { + EntityPlayer player = (EntityPlayer) event.source.getEntity(); + ItemStack stack = player.getCurrentEquippedItem(); + if (stack != null && stack.hasTagCompound() && stack.getItem() instanceof ToolCore) + { + int beheading = stack.getTagCompound().getCompoundTag("InfiTool").getInteger("Beheading"); + if (stack.getItem() == TContent.cleaver) + beheading += 2; + if (beheading > 0 && random.nextInt(100) < beheading * 5) { - int beheading = stack.getTagCompound().getCompoundTag("InfiTool").getInteger("Beheading"); - if (stack.getItem() == TContent.cleaver) - beheading += 2; - if (beheading > 0 && random.nextInt(100) < beheading * 5) - { - addDrops(event, new ItemStack(Item.skull.itemID, 1, 4)); - } + addDrops(event, new ItemStack(Item.skull.itemID, 1, 4)); } } } } + } - else if (event.entityLiving.getClass() == EntityGhast.class) + if (event.entityLiving.getClass() == EntityGhast.class) + { + if (PHConstruct.uhcGhastDrops) + { + for (EntityItem o : event.drops) + { + if (o.getEntityItem().itemID == Item.ghastTear.itemID) + { + o.setEntityItemStack(new ItemStack(Item.ingotGold, 1)); + } + } + } + else { addDrops(event, new ItemStack(Item.ghastTear, 1)); } + } //} - + if (event.entityLiving instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) event.entityLiving; - if (event.source.damageType.equals("player")) + if (PHConstruct.dropPlayerHeads) + { + ItemStack dropStack = new ItemStack(Item.skull.itemID, 1, 3); + NBTTagCompound nametag = new NBTTagCompound(); + nametag.setString("SkullOwner", player.username); + addDrops(event, dropStack); + } + + else if (event.source.damageType.equals("player")) { EntityPlayer source = (EntityPlayer) event.source.getEntity(); ItemStack stack = source.getCurrentEquippedItem(); @@ -291,6 +313,41 @@ public class TEventHandler } } + /* Chunks */ + /*@ForgeSubscribe + public void chunkDataLoad (ChunkDataEvent.Load event) + { + ChunkCoordTuple coord = new ChunkCoordTuple(event.getChunk().xPosition, event.getChunk().zPosition); + int worldID = event.getChunk().worldObj.provider.dimensionId; + int crystal = event.getData().getInteger("TConstruct.Crystallinity"); + + HashMap crystalMap = TheftValueTracker.crystallinity.get(worldID); + if (crystalMap == null) + { + crystalMap = new HashMap(); + TheftValueTracker.crystallinity.put(worldID, crystalMap); + } + crystalMap.put(coord, crystal); + } + + @ForgeSubscribe + public void chunkDataSave (ChunkDataEvent.Save event) + { + ChunkCoordTuple coord = new ChunkCoordTuple(event.getChunk().xPosition, event.getChunk().zPosition); + int worldID = event.getChunk().worldObj.provider.dimensionId; + HashMap crystalMap = TheftValueTracker.crystallinity.get(worldID); + + if (crystalMap.containsKey(coord)) + { + int crystal = crystalMap.get(coord); + event.getData().setInteger("TConstruct.Crystallinity", crystal); + if (!event.getChunk().isChunkLoaded) + { + TheftValueTracker.crystallinity.remove(worldID); + } + } + }*/ + /* Ore Dictionary */ @ForgeSubscribe public void registerOre (OreRegisterEvent evt) diff --git a/mods/tinker/tconstruct/util/player/TFoodStats.java b/mods/tinker/tconstruct/util/player/TFoodStats.java index ef768fb..9c51de3 100644 --- a/mods/tinker/tconstruct/util/player/TFoodStats.java +++ b/mods/tinker/tconstruct/util/player/TFoodStats.java @@ -1,6 +1,6 @@ package mods.tinker.tconstruct.util.player; -import mods.tinker.tconstruct.TConstruct; +import mods.tinker.tconstruct.util.PHConstruct; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemFood; import net.minecraft.nbt.NBTTagCompound; @@ -63,7 +63,7 @@ public class TFoodStats extends FoodStats } } - if (this.foodLevel >= 12 + 2*difficulty && player.shouldHeal()) + if (this.foodLevel >= 12 + 2*difficulty && player.shouldHeal() && PHConstruct.enableHealthRegen) { ++this.foodTimer; diff --git a/mods/tinker/tconstruct/util/player/TPlayerHandler.java b/mods/tinker/tconstruct/util/player/TPlayerHandler.java index 55a682b..8a029e5 100644 --- a/mods/tinker/tconstruct/util/player/TPlayerHandler.java +++ b/mods/tinker/tconstruct/util/player/TPlayerHandler.java @@ -79,6 +79,13 @@ public class TPlayerHandler implements IPlayerTracker //stats.armor.recalculateSkills(entityplayer, stats); playerStats.put(entityplayer.username, stats); + + if (PHConstruct.gregtech) + { + PHConstruct.gregtech = false; + entityplayer.addChatMessage("Warning: GregTech Exploit Present!"); + entityplayer.addChatMessage("Please disable all Reverse Smelting recipes from GregTech."); + } //sendSkills(entityplayer, stats); } diff --git a/mods/tinker/tconstruct/worldgen/TBaseWorldGenerator.java b/mods/tinker/tconstruct/worldgen/TBaseWorldGenerator.java index d3120ba..a4bf744 100644 --- a/mods/tinker/tconstruct/worldgen/TBaseWorldGenerator.java +++ b/mods/tinker/tconstruct/worldgen/TBaseWorldGenerator.java @@ -1,8 +1,11 @@ package mods.tinker.tconstruct.worldgen; +import java.util.HashMap; import java.util.Random; import mods.tinker.tconstruct.common.TContent; +import mods.tinker.tconstruct.crystal.TheftValueTracker; +import mods.tinker.tconstruct.library.util.ChunkCoordTuple; import mods.tinker.tconstruct.library.util.CoordTuple; import mods.tinker.tconstruct.util.PHConstruct; import net.minecraft.block.Block; @@ -42,6 +45,8 @@ public class TBaseWorldGenerator implements IWorldGenerator @Override public void generate (Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { + initializeChunkData(chunkX, chunkZ, world.provider.dimensionId); + if (world.provider.isHellWorld) { generateNether(random, chunkX * 16, chunkZ * 16, world); @@ -57,6 +62,24 @@ public class TBaseWorldGenerator implements IWorldGenerator { superfunGenerate(random, chunkX * 16, chunkZ * 16, world); } + + if (PHConstruct.worldBorder) + { + generateChunkBorder(random, chunkX * 16, chunkZ * 16, world); + } + } + + void initializeChunkData(int chunkX, int chunkZ, int worldID) + { + ChunkCoordTuple coord = new ChunkCoordTuple(chunkX, chunkZ); + int crystal = 0; + HashMap crystalMap = TheftValueTracker.crystallinity.get(worldID); + if (crystalMap == null) + { + crystalMap = new HashMap(); + TheftValueTracker.crystallinity.put(worldID, crystalMap); + } + crystalMap.put(coord, crystal); } void generateSurface (Random random, int xChunk, int zChunk, World world) @@ -343,6 +366,23 @@ public class TBaseWorldGenerator implements IWorldGenerator } } + void generateChunkBorder (Random random, int chunkX, int chunkZ, World world) + { + for (int x = 0; x < 16; x++) + { + for (int z = 0; z < 16; z++) + { + if (x + chunkX == PHConstruct.worldBorderSize || x + chunkX == -PHConstruct.worldBorderSize || z + chunkZ == PHConstruct.worldBorderSize || z + chunkZ == -PHConstruct.worldBorderSize) + { + for (int y = 0; y < 256; y++) + { + world.setBlock(x + chunkX, y, z + chunkZ, Block.bedrock.blockID, 0, 0); + } + } + } + } + } + WorldGenMinable copper; WorldGenMinable tin; WorldGenMinable aluminum; diff --git a/mods/tinker/textures/blocks/amber_crystal.png b/mods/tinker/textures/blocks/amber_crystal.png new file mode 100644 index 0000000000000000000000000000000000000000..7acc49b0557116c4116a73ed6fa82931c7dca4ec GIT binary patch literal 346 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucL8%hgh?3y^w370~qEv=}#LT=BJwMkFg)(D3 zQ$0figD*u3fvQe=x;Tbd_{UB<$m`_D;qvmC{F_7FrGNb199+EjMx$uOHkS9BDraw> z?0bSOLLy;7-1Cn+X$)f0;w{kJ7ZV>PAnFy4(3%51m^y z?NFvML+GMQO9fmkgyLK0u4P_0U*_IFDNdnBUtEk=%RG{C)|O2C?)lD3VN3Iwlh+bC z?|8m;3t3mRxccHO>vO7J+Mj)zopr08?p(^b literal 0 HcmV?d00001 diff --git a/mods/tinker/textures/items/skull_char_gold.png b/mods/tinker/textures/items/skull_char_gold.png new file mode 100644 index 0000000000000000000000000000000000000000..fa83380fe952476685cc0d0d13124038a81ce198 GIT binary patch literal 406 zcmV;H0crk;P)sa zvQ)ZBOC=N=p{AB&h(l8=O(m@ze3tX^a?Z<{98gxZibW?9;ba!ELWdKlNX>N2bPDNB8 zb~7$DE-^4L^m3s900wDEL_t(|UgerSZXGuig}ny1*@9bFhV8}+5RfvBN&#sV7Xb_b z*?^EPm3NT^q)C-kWFr$C1D}0-bjcw(?;Uc4CmyScg9Zf|e5 zySuyZe$_@hec7h=>+9=HbIe{Er)zMT=MzK8`}_MZ3h!MBhLpIvx|+V;{QTx}0BBjd z0z&`@EC2%lEXr?!QuSX11Kgs{f}}KHAfs`*BqwFv6)IM!O>;=zK|3F}2WLhREQ_Kj zCgq3|87mS1#`XY^%tZm<7EJ~~V+TMo&YEO^E9hww1YFF%wGC)24MZSzr6kG&$FpeY4D-|@L-sM zk+kRSAAbL^z5n$7y8_4qXr?`XcGnuT)4Z53)~%b0qFkk93ly~r06^%msFh~(z4@Gs zoJL?Tr?*Pi42lUP<79og0J)vt44f?xoh^((*1{Tqa(a*Qj(*Eh8ZSTgs&Mo@ zJ&;@Lng+m?s21jm`AfII|Jw5U_wyecSLIqgpdFxIplxL!-Zu?ETBb!!sH+!AaTLw_ zKY#jh)2053AuSiEsNVB`2h$6%X#iS?`lMQ%2ftL>ncx6;9pL`EXW^vxo-6o#(*R`U z){E%slOnP%O2dSIK7HK$QhS0pqe#V+YQDo+ASa;Oqlf_z zzJQ=#2Y|7y6zc817pS7W?=dn%Ep3}Ci)UbDYl>Ce|Dim;upj}bfUaBwu=bc(xzQ2; z8q|vPZvBb@1Uo5<;xHirs1!p9-!S=k02WSVv)wmO(=os)*NO*}r@TnYd9c&H(;r~) zS&p?TtKn9#jP+D$w2C2K$SpHqk8Zw`OE>V`@AoLHu>jC>H}&~@@) z0egx8mBP6>$qkYBw-h;-3pguXX$My_!vIT|?JbIB41l_T zxhVityK6H80J>KjXeR(JzmgVvW2Br;kwtm8Hfuw{tRcJ|S*k|Or8!I2*mD67Jlv;? zRQvMPHqEVo$3H}{w&wFPoB69iow0&+Sq4Ya3v{ZUv%XJ+ot}B7n6*28+mn;>ywkx> ztNYx(Cdv5`oSvy-AGk(Zc;&eov)blhqe!d#&P|n%Z2|HCfXty@@8hc;ZTTk$>4&`Q zmOawuyTFQR>Q}qVrNwXx~g2j<=q`l#Q+CDAdr%0^%|DPxK5aL>4;s|ure!xy)2Mh zPywMfcaf~b=%d}AM`WcqwD-lO^<(n4b%pqk~29E}(mRwb*qu5>zpZyxQ zqQjvvxx=b!E$*A5WC@D)*mDXU4$aX5 zz!&X1s!GY0f}9id`VTGs6odC%V6Wd9-~|)eBLD53@~6<@f1RTT09)+drs}a5PX^-~ zr^D}e3n$eRfb2i?4~)f?pB#X_AlU1FOaS<18JFf`jzt{54a4s_8}O4QKeoyb9*{r0 zfWZlt0pNHV#fa=YbL7m%sgjpWep|rVUe*W9%lE~D`t6EoeXLRMKbo{E8Y^?3FG_z9QNF{e(u$UPN-XAeMrcK0afjhDop76AVNa|GrCvy#?( P00000NkvXXu0mjfoHSD% literal 0 HcmV?d00001 diff --git a/mods/tinker/textures/mob/crystalGuardTurquoise.png b/mods/tinker/textures/mob/crystalGuardTurquoise.png new file mode 100644 index 0000000000000000000000000000000000000000..1476a8ef565c0f11ea61bd268ff8906e157e0edc GIT binary patch literal 1764 zcmVN2bPDNB8 zb~7$DE-^4L^m3s900v-5L_t(|Uget2Z5&4sg%ySm&P0%OQ2-2q@QHx0^u>U{5C~19DUYG<1yVG6$Q?FkAbaUUlY5v{a-JS05?@td84?lgX zjduF7P3^b0wZ7IhXRr2zvOjngAJDeJCKu|jQ{L-G#V<+$CP8AY%xilUg5BTi(j zNB|f+13)rY1%O*L832tP0LeIOk^!!uy8#UFetmD+>2hN3|EZX}L1qAeaBCtzVnFs^ z1pwL<^v?)C3WDzcM}nZ%zMN^BGo#E_`f~{Eo^x>xh$OCAmJ%4xCYT9YPm~Ymtn~I`brQ`?{wF>}1n6YS-W^>(qPe$%WU@NDO zO4kgE2_)lWeYpU+ozD!MBM_Y}j6v4HKyC>D(64g(jPj2D$Wj_FKlZAyyUq;c(Y|&A z;7U{*bHzNWKYjmx%IBY_rxOoZ!>K(3+5wsc+EE5#Z@U3V%Z#WAb+r(RyTbbZ>D#yG zNADFwMlMiMedhlTrWatl0T?0blWKDw`~-j$tXQD7-@knM(eI3L|J|~1(tFDle7@ZP zWaT!C=<1UqSX-ZeeEs_Tpg5li;vPjRrd0DC&H_1sl&n&n^0NaV#gq290DWwjv7;2~ z?S2-hqP?FnGD9sLn=6ZFVB~0uRZv`(_6Ify2+24A70{K70M-^0D>qsKK!d7C?;D^x zg8{ff2Eoh%4nU*S5nY>!%#b(R=V1t$+SzA@iOm8a+@8yBl?fB!!iJ}j*h5&j*hG9S54nN&PtxAJI431I(CTxqhcs6qfL#9n2Mre2%uHz zEypBVMlp%P%=g0BB>-k;a{9Q@?Z~Fgp0Rsmt95n*kOM}A5Z3B0uyxJ>7jl&gc(CbCTmj%#>du3lf@!AEs?-LI_WYH?c{qUq zl(XJHTIfm4<={%D4S<9>+oM><0H_OCE*+;RaAJbX_Vsm|rAZJJvF zkAH|@?Yv`T{wh#stRP*M!IAU=ovQb&?-OCCrz?(+?roFutm$B<)%{%Hdy*V$GKMPl zg=?gRSKg~Jt8ET8ij2x{UnA>-5g;!B$Qezm(? zTHN;nNHF^a00f)L1yFY80(oF@Yvs5OD`o+5tGw<6fL5o=dt*&wNyd&YKJ+bifU zkXKig3%I+GTNQ@84U>tO#utK3OQ`ds_JD z`-%>S#yC~IoJ=bFp~?HIa+J*C^?Y@x@^yHSw$suuS{QL+T3XY9F@UhR2D0Qjc; zL{%v{QZWBLo^pq7Z`&Gf2yVH+R=+dA3nsFKl$@O@&ZWnHHqQ(Ij@Z`(02z!QcpV1L zEu0ij0ItCW&JMs<5S;b@${4_JmT_rLn1>mF-*ZUvo25*9etC-g;SDq=SO$RWX%s^V z-nnw-;8e*=CVyMN-CouQ%**eKoBC~vX@BfdYx0x6&4K?HfmaW}`@i3x^x&2kziYfU z=Dd0U{Dw>Em|Lf7Gt|ZQ^XdV}pWXeE`^Jlzb7A5U0RI9!W(V5=`gb+}0000N2bPDNB8 zb~7$DE-^4L^m3s900vx1L_t(|UgeriY8^)ug}oaOvIJurf+15aL7oXRRVD_bEFd64 zhS^JYkQHPYvV@FZID*d{AKm(GJ^2v{ny0S1RbBVobAPJ3U%i_AySceJ-QM1w?(Xis z`c)h4^ktjcudlC9nq&3SI9-#=Jf9d!-rwIpC_K6n3@LGSb+vrG`SH!=0MN2@1%?0+ zSO5k9Sd`xcrRu*32Dn9?1xabZKt|(qNlwbTD^#pdo92+bgLXb{PtJ@YSQbT5Ov(`_ zGFBu2jO_s+nTrCzEt(8~#twjFoHfY+SJ2%626(^zpS08Y#N7W=F?WN^0080EM83s< z?7s*Av?%DG5xx}!-T#jSK|T9?rk$J_Wk%`G8G!ZQ{`B^XKd+`jrNN5=z=L51M$(?Q zfB5yo>HX*TUll+eKr`+6y}Q<=oz}&Cv2NW|6y+)~y;#tc8q-9#vgt~eV%BRBr{Qkp< zOMMkXS}ssgz32Z9rWat#0JISGNwqi+egZ%W>erS2>*wzt?*I7s`k~+J0QcXKg_GVR zSMd3k0m#a&7tz%xMWmb*mBN7GZ2*uUt|(G5rJC<>7RU*tWR>capB(_V_HW<6KIxL; z03$$HFk@RO)Z2Y8P(^#+V`PTf+BR1f&%nsm6suruDeRX(0hk1!0=jY$z#1{Ja-%H( zG^mR7z5uE-XFvwP>fRYpDTWfhVe<0;ES$<_yKkPBV}Mhx6%PQQRTTBwH7CbfmDKhtI1iBfNkdM3}=Vn7v~JlOccd?8hy z&f+J*BkfieuFec9)>Mq!20+%)7M0)Dc2)hV>1VgIlINNoHD;L<=ZB+ocm1coNPQf%&s8^aEu$LH6 zDV&=V7(hAe{Vhe#bwe78+= zE8y`$1Z!(PFSD7y3e*`ZNS9@BB)#~q$`MQeQogk{b;>#z_-(IE%A;(xPiX;x4(exq zWT|2wxkja6ZfHjL)f~HR{wx$}mEZo1tPk9X4#*<_GKYG-kFR>Pv*VyvfpSz{&jjQrcY!0;uEw%JQZeU@ z(`jv0&|M&pt|}LBd3T3o$u27#0Ny(YgjKz!^Ov5}?Dan<0DQBIOS8i~%mDnJvjIv{12