Skip to content

Commit

Permalink
Slimy trait now has a small chance to summon a small slime when break…
Browse files Browse the repository at this point in the history
…ing blocks :3
  • Loading branch information
bonii-xx committed Oct 21, 2014
1 parent b7bd575 commit bd02e54
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 4 deletions.
2 changes: 2 additions & 0 deletions resources/META-INF/TConstruct_at.cfg
Expand Up @@ -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
65 changes: 61 additions & 4 deletions src/main/java/tconstruct/tools/TActiveOmniMod.java
Expand Up @@ -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;
Expand All @@ -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
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand All @@ -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)
{
Expand Down

2 comments on commit bd02e54

@TherminatorX
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

//minislime! :3

@PrincessOfEvil
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Free repair! Yay!

Please sign in to comment.