mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-10-26 14:24:40 +00:00
Wither skeletons will now drop necrotic bones and respect beheading
This commit is contained in:
1 parent
c9946e21ec
commit
bf211db416
2 files changed
+67
-6
No files matched your search
@@ -1,15 +1,22 @@
|
||||
package crazypants.enderio.entity;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.IEntityLivingData;
|
||||
import net.minecraft.entity.SharedMonsterAttributes;
|
||||
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
||||
import net.minecraft.entity.monster.EntitySkeleton;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.Calendar;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import crazypants.util.EntityUtil;
|
||||
|
||||
public class EntityWitherSkeleton extends EntitySkeleton {
|
||||
public EntityWitherSkeleton(World world) {
|
||||
@@ -54,4 +61,33 @@ public class EntityWitherSkeleton extends EntitySkeleton {
|
||||
public int getSkeletonType() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeath(DamageSource source) {
|
||||
super.onDeath(source);
|
||||
if(source.damageType.equals("player")) {
|
||||
EntityPlayer player = (EntityPlayer) source.getEntity();
|
||||
ItemStack stack = player.getCurrentEquippedItem();
|
||||
if(stack != null && stack.hasTagCompound()) {
|
||||
Item cleaver = GameRegistry.findItem("TConstruct", "cleaver");
|
||||
int beheading = stack.getTagCompound().getCompoundTag("InfiTool").getInteger("Beheading");
|
||||
if(stack.getItem() == cleaver) {
|
||||
beheading += 2;
|
||||
}
|
||||
System.out.println(beheading);
|
||||
if(beheading > 0 && worldObj.rand.nextInt(100) < beheading * 10) {
|
||||
EntityUtil.spawnItemInWorldWithRandomMotion(worldObj, new ItemStack(Items.skull, 1, 1), posX, posY, posZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(source.getEntity() instanceof EntityLivingBase) {
|
||||
int lootingLevel = EnchantmentHelper.getLootingModifier((EntityLivingBase) source.getEntity());
|
||||
if(worldObj.rand.nextInt(Math.max(1, 1 - lootingLevel)) == 0) {
|
||||
Item necroticBone = GameRegistry.findItem("TConstruct", "materials");
|
||||
if(necroticBone != null) {
|
||||
EntityUtil.spawnItemInWorldWithRandomMotion(worldObj, new ItemStack(necroticBone, 1, 8), posX, posY, posZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,18 +5,18 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import crazypants.vecmath.Vector3d;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.boss.IBossDisplayData;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import crazypants.vecmath.Vector3d;
|
||||
|
||||
public class EntityUtil {
|
||||
|
||||
@@ -65,5 +65,30 @@ public class EntityUtil {
|
||||
}
|
||||
return collidingBoundingBoxes;
|
||||
}
|
||||
|
||||
|
||||
public static void spawnItemInWorldWithRandomMotion(World world, ItemStack item, int x, int y, int z) {
|
||||
if(item != null) {
|
||||
spawnItemInWorldWithRandomMotion(world, item, x + 0.5, y + 0.5, z + 0.5);
|
||||
}
|
||||
}
|
||||
|
||||
public static void spawnItemInWorldWithRandomMotion(World world, ItemStack item, double x, double y, double z) {
|
||||
if(item != null) {
|
||||
spawnItemInWorldWithRandomMotion(new EntityItem(world, x, y, z, item));
|
||||
}
|
||||
}
|
||||
|
||||
public static void spawnItemInWorldWithRandomMotion(EntityItem entity) {
|
||||
entity.delayBeforeCanPickup = 10;
|
||||
|
||||
float f = (entity.worldObj.rand.nextFloat() * 0.1f) - 0.05f;
|
||||
float f1 = (entity.worldObj.rand.nextFloat() * 0.1f) - 0.05f;
|
||||
float f2 = (entity.worldObj.rand.nextFloat() * 0.1f) - 0.05f;
|
||||
|
||||
entity.motionX += f;
|
||||
entity.motionY += f1;
|
||||
entity.motionZ += f2;
|
||||
|
||||
entity.worldObj.spawnEntityInWorld(entity);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user