Unique Wither Skeleton Entity

This commit is contained in:
hilburn committed 2015-01-06 01:40:16 +00:00
1 parent 23dbf935e6
commit cd4a958784
5 files changed
+95 -1

No files matched your search

@@ -6,6 +6,7 @@ import java.io.FileWriter;
import java.lang.reflect.Field;
import java.util.List;
import crazypants.enderio.entity.SkeletonHandler;
import net.minecraft.block.material.Material;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
@@ -561,6 +562,8 @@ public class EnderIO {
ConduitBundledRedstoneProvider.register();
}
SkeletonHandler.registerSkeleton(this);
EnderfaceRecipes.addRecipes();
MaterialRecipes.addRecipes();
ConduitRecipes.addRecipes();
@@ -0,0 +1,55 @@
package crazypants.enderio.entity;
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.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import java.util.Calendar;
public class EntityWitherSkeleton extends EntitySkeleton
{
public EntityWitherSkeleton(World world)
{
super(world);
}
public EntityWitherSkeleton(EntitySkeleton entity)
{
this(entity.worldObj);
this.copyLocationAndAnglesFrom(entity);
}
@Override
public void setFire(int p_70015_1_)
{
}
@Override
public IEntityLivingData onSpawnWithEgg(IEntityLivingData entityData)
{
this.getEntityAttribute(SharedMonsterAttributes.followRange).applyModifier(new AttributeModifier("Random spawn bonus", this.rand.nextGaussian() * 0.05D, 1));
this.setSkeletonType(1);
this.setCurrentItemOrArmor(0, new ItemStack(Items.stone_sword));
this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(4.0D);
this.setCombatTask();
this.setCanPickUpLoot(this.rand.nextFloat() < 0.55F * this.worldObj.func_147462_b(this.posX, this.posY, this.posZ));
if (this.getEquipmentInSlot(4) == null)
{
Calendar calendar = this.worldObj.getCurrentDate();
if (calendar.get(2) + 1 == 10 && calendar.get(5) == 31 && this.rand.nextFloat() < 0.25F)
{
this.setCurrentItemOrArmor(4, new ItemStack(this.rand.nextFloat() < 0.1F ? Blocks.lit_pumpkin : Blocks.pumpkin));
this.equipmentDropChances[4] = 0.0F;
}
}
return entityData;
}
}
@@ -0,0 +1,30 @@
package crazypants.enderio.entity;
import cpw.mods.fml.common.eventhandler.EventPriority;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.registry.EntityRegistry;
import crazypants.enderio.EnderIO;
import net.minecraft.entity.monster.EntitySkeleton;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
public class SkeletonHandler
{
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void skeletonJoinWorld(EntityJoinWorldEvent event)
{
if (event.entity.getClass() == EntitySkeleton.class && ((EntitySkeleton)event.entity).getSkeletonType()==1)
{
event.setCanceled(true);
event.world.spawnEntityInWorld(new EntityWitherSkeleton((EntitySkeleton)event.entity));
}
}
public static void registerSkeleton(EnderIO mod)
{
int entityID = EntityRegistry.findGlobalUniqueEntityId();
EntityRegistry.registerGlobalEntityID(EntityWitherSkeleton.class,"witherSkeleton", entityID, 0x00003D, 0x751947);
EntityRegistry.registerModEntity(EntityWitherSkeleton.class,"witherSkeleton",entityID,mod,64,3,true);
MinecraftForge.EVENT_BUS.register(new SkeletonHandler());
}
}