From bd02e5419f0021e223bc8bd703bfb5ddbeb601a7 Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Tue, 21 Oct 2014 17:10:28 +0200 Subject: [PATCH] Slimy trait now has a small chance to summon a small slime when breaking blocks :3 --- resources/META-INF/TConstruct_at.cfg | 2 + .../java/tconstruct/tools/TActiveOmniMod.java | 65 +++++++++++++++++-- 2 files changed, 63 insertions(+), 4 deletions(-) diff --git a/resources/META-INF/TConstruct_at.cfg b/resources/META-INF/TConstruct_at.cfg index 5446467f1bc..e00d0b132fb 100644 --- a/resources/META-INF/TConstruct_at.cfg +++ b/resources/META-INF/TConstruct_at.cfg @@ -38,4 +38,6 @@ public net.minecraft.client.multiplayer.PlayerControllerMP func_85182_a(III)Z #s public net.minecraft.server.management.ItemInWorldManager field_73086_f public net.minecraft.server.management.ItemInWorldManager field_73087_g public net.minecraft.server.management.ItemInWorldManager field_73099_h +# EntitySlime +public net.minecraft.entity.monster.EntitySlime func_70799_a(I)V #setSlimeSize # needs to have a space at the end of every line or SS will derp diff --git a/src/main/java/tconstruct/tools/TActiveOmniMod.java b/src/main/java/tconstruct/tools/TActiveOmniMod.java index f14cf51be63..7cbcb30db1c 100644 --- a/src/main/java/tconstruct/tools/TActiveOmniMod.java +++ b/src/main/java/tconstruct/tools/TActiveOmniMod.java @@ -5,6 +5,7 @@ import net.minecraft.enchantment.*; import net.minecraft.entity.*; import net.minecraft.entity.item.*; +import net.minecraft.entity.monster.EntitySlime; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.*; import net.minecraft.item.crafting.FurnaceRecipes; @@ -16,6 +17,7 @@ import tconstruct.library.tools.*; import tconstruct.util.config.PHConstruct; import tconstruct.world.TinkerWorld; +import tconstruct.world.entity.BlueSlime; public class TActiveOmniMod extends ActiveToolMod { @@ -56,6 +58,12 @@ public boolean beforeBlockBreak (ToolCore tool, ItemStack stack, int x, int y, i return false; } + @Override + public void afterBlockBreak(ToolCore tool, ItemStack stack, Block block, int x, int y, int z, EntityLivingBase entity) { + NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool"); + slimify(tool, tags, block, x,y,z, entity.worldObj); + } + private boolean autoSmelt (ToolCore tool, NBTTagCompound tags, ItemStack stack, int x, int y, int z, EntityLivingBase entity) { World world = entity.worldObj; @@ -168,11 +176,12 @@ public int baseAttackDamage (int earlyModDamage, int damage, ToolCore tool, NBTT private void baconator (ToolCore tool, ItemStack stack, EntityLivingBase entity, NBTTagCompound tags) { + final int pigiron = TinkerTools.MaterialID.PigIron; int bacon = 0; - bacon += tags.getInteger("Head") == 18 ? 1 : 0; - bacon += tags.getInteger("Handle") == 18 ? 1 : 0; - bacon += tags.getInteger("Accessory") == 18 ? 1 : 0; - bacon += tags.getInteger("Extra") == 18 ? 1 : 0; + bacon += tags.getInteger("Head") == pigiron ? 1 : 0; + bacon += tags.getInteger("Handle") == pigiron ? 1 : 0; + bacon += tags.getInteger("Accessory") == pigiron ? 1 : 0; + bacon += tags.getInteger("Extra") == pigiron ? 1 : 0; int chance = tool.getPartAmount() * 100; if (random.nextInt(chance) < bacon) { @@ -183,6 +192,54 @@ private void baconator (ToolCore tool, ItemStack stack, EntityLivingBase entity, } } + private void slimify(ToolCore tool, NBTTagCompound tags, Block block, int x, int y, int z, World world) + { + if (world.isRemote) + return; + + int chance = tool.getPartAmount() * 100; + int count = 0; + int slimeMat = TinkerTools.MaterialID.Slime; + + // regular slime + if(tags.getInteger("Head") == slimeMat) + count++; + if(tags.getInteger("Handle") == slimeMat) + count++; + if(tags.getInteger("Accessory") == slimeMat) + count++; + if(tags.getInteger("Extra") == slimeMat) + count++; + + if(random.nextInt(chance) < count) { + EntitySlime entity = new EntitySlime(world); + entity.setPosition(x+0.5,y,z+0.5); + entity.setSlimeSize(1); // minislime! + world.spawnEntityInWorld(entity); + entity.playLivingSound(); + } + + // blueslime + slimeMat = TinkerTools.MaterialID.BlueSlime; + count = 0; + if(tags.getInteger("Head") == slimeMat) + count++; + if(tags.getInteger("Handle") == slimeMat) + count++; + if(tags.getInteger("Accessory") == slimeMat) + count++; + if(tags.getInteger("Extra") == slimeMat) + count++; + + if(random.nextInt(chance) < count) { + BlueSlime entity = new BlueSlime(world); + entity.setPosition(x+0.5,y,z+0.5); + entity.setSlimeSize(1); // minislime! + world.spawnEntityInWorld(entity); + entity.playLivingSound(); + } + } + @Override public int attackDamage (int modDamage, int currentDamage, ToolCore tool, NBTTagCompound tags, NBTTagCompound toolTags, ItemStack stack, EntityLivingBase player, Entity entity) {