mirror of
https://github.com/GTNewHorizons/IguanaTweaksTConstruct.git
synced 2026-11-26 14:53:02 +00:00
It's raining mobheads
This commit is contained in:
1 parent
edd6c7e59e
commit
2ea499ba5d
4 files changed
+114
-9
No files matched your search
@@ -5,9 +5,10 @@ import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import iguanaman.iguanatweakstconstruct.mobheads.blocks.IguanaSkullBlock;
|
||||
import iguanaman.iguanatweakstconstruct.mobheads.handlers.MobHeadHandler;
|
||||
import iguanaman.iguanatweakstconstruct.mobheads.items.IguanaSkull;
|
||||
import iguanaman.iguanatweakstconstruct.mobheads.proxy.MobHeadCommonProxy;
|
||||
import iguanaman.iguanatweakstconstruct.mobheads.renderers.RenderPlayerHandler;
|
||||
import iguanaman.iguanatweakstconstruct.mobheads.handlers.RenderPlayerHandler;
|
||||
import iguanaman.iguanatweakstconstruct.mobheads.tileentities.IguanaSkullTileEntity;
|
||||
import iguanaman.iguanatweakstconstruct.reference.Reference;
|
||||
import mantle.pulsar.pulse.Handler;
|
||||
@@ -44,6 +45,7 @@ public class IguanaMobHeads {
|
||||
public void postInit(FMLPostInitializationEvent event)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.register(new RenderPlayerHandler());
|
||||
MinecraftForge.EVENT_BUS.register(new MobHeadHandler());
|
||||
|
||||
proxy.postInit();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
package iguanaman.iguanatweakstconstruct.mobheads.handlers;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.EventPriority;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.registry.EntityRegistry;
|
||||
import iguanaman.iguanatweakstconstruct.mobheads.IguanaMobHeads;
|
||||
import iguanaman.iguanatweakstconstruct.mobheads.items.IguanaSkull;
|
||||
import iguanaman.iguanatweakstconstruct.reference.Config;
|
||||
import iguanaman.iguanatweakstconstruct.util.Log;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.monster.*;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
import net.minecraftforge.event.entity.living.LivingDropsEvent;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Random;
|
||||
|
||||
public class MobHeadHandler {
|
||||
private static Random random = new Random();
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.LOWEST)
|
||||
public void LivingDrops(LivingDropsEvent event)
|
||||
{
|
||||
// remove regular skull drops (because we modify its drop chance)
|
||||
Iterator<EntityItem> i = event.drops.iterator();
|
||||
while (i.hasNext()) {
|
||||
EntityItem eitem = i.next();
|
||||
|
||||
if (eitem != null)
|
||||
if (eitem.getEntityItem() != null)
|
||||
{
|
||||
ItemStack item = eitem.getEntityItem();
|
||||
if (item.getItem() == Items.skull && item.getItemDamage() != 3)
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
|
||||
// add our own drops if the damage source was a player (and no fake player)
|
||||
Entity entity = event.source.getEntity();
|
||||
if(entity == null)
|
||||
return;
|
||||
if(!(entity instanceof EntityPlayer) || entity instanceof FakePlayer)
|
||||
return;
|
||||
|
||||
// how much beheading chance do we have?
|
||||
EntityPlayer player = (EntityPlayer) event.source.getEntity();
|
||||
ItemStack stack = player.getCurrentEquippedItem();
|
||||
int beheading = 0;
|
||||
if (stack != null && stack.hasTagCompound() && stack.getItem() instanceof ToolCore)
|
||||
{
|
||||
beheading = stack.getTagCompound().getCompoundTag("InfiTool").getInteger("Beheading");
|
||||
if (stack.getItem() == TinkerTools.cleaver)
|
||||
beheading += 2;
|
||||
}
|
||||
// roll the dice
|
||||
if(random.nextInt(100) > beheading * Config.beheadingHeadDropChance + Config.baseHeadDropChance)
|
||||
return;
|
||||
|
||||
Item skullItem = null;
|
||||
int skullId = -1;
|
||||
|
||||
Entity mob = event.entityLiving;
|
||||
// skelly/witherskelly
|
||||
if (mob instanceof EntitySkeleton) {
|
||||
skullItem = Items.skull;
|
||||
skullId = ((EntitySkeleton) event.entityLiving).getSkeletonType();
|
||||
}
|
||||
else if (mob instanceof EntityPigZombie) {
|
||||
skullItem = IguanaMobHeads.skullItem;
|
||||
skullId = IguanaSkull.META_PIGZOMBIE;
|
||||
}
|
||||
else if (mob instanceof EntityZombie) {
|
||||
skullItem = Items.skull;
|
||||
skullId = 2;
|
||||
}
|
||||
else if (mob instanceof EntityCreeper) {
|
||||
skullItem = Items.skull;
|
||||
skullId = 4;
|
||||
}
|
||||
else if (mob instanceof EntityEnderman) {
|
||||
skullItem = IguanaMobHeads.skullItem;
|
||||
skullId = IguanaSkull.META_ENDERMAN;
|
||||
}
|
||||
else if (mob instanceof EntityBlaze) {
|
||||
skullItem = IguanaMobHeads.skullItem;
|
||||
skullId = IguanaSkull.META_BLAZE;
|
||||
}
|
||||
|
||||
// no skull found?
|
||||
if(skullItem == null)
|
||||
return;
|
||||
|
||||
// drop it like it's hot
|
||||
EntityItem entityitem = new EntityItem(mob.worldObj, mob.posX, mob.posY, mob.posZ, new ItemStack(skullItem, 1, skullId));
|
||||
entityitem.delayBeforeCanPickup =10;
|
||||
event.drops.add(entityitem);
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -1,4 +1,4 @@
|
||||
package iguanaman.iguanatweakstconstruct.mobheads.renderers;
|
||||
package iguanaman.iguanatweakstconstruct.mobheads.handlers;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@@ -6,6 +6,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
import iguanaman.iguanatweakstconstruct.IguanaTweaksTConstruct;
|
||||
import iguanaman.iguanatweakstconstruct.claybuckets.IguanaItems;
|
||||
import iguanaman.iguanatweakstconstruct.mobheads.IguanaMobHeads;
|
||||
import iguanaman.iguanatweakstconstruct.mobheads.renderers.IguanaTileEntitySkullRenderer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.client.event.RenderPlayerEvent;
|
||||
@@ -21,13 +21,9 @@ import net.minecraft.world.World;
|
||||
import java.util.List;
|
||||
|
||||
public class IguanaSkull extends net.minecraft.item.ItemSkull {
|
||||
public static final int META_ZOMBIE = 2;
|
||||
public static final int META_SKELETON = 0;
|
||||
public static final int META_ENDERMAN = 5;
|
||||
public static final int META_PIGMAN = 6;
|
||||
public static final int META_BLAZE = 7;
|
||||
public static final int META_STEVE = 3;
|
||||
public static final int META_CREEPER = 4;
|
||||
public static final int META_ENDERMAN = 0;
|
||||
public static final int META_PIGZOMBIE = 1;
|
||||
public static final int META_BLAZE = 2;
|
||||
|
||||
private static final String[] skullTypes = new String[] {"enderman", "pigman", "blaze"};
|
||||
public static final String[] field_94587_a = new String[] {"skull_enderman", "skull_pigman", "skull_blaze"};
|
||||
|
||||
Reference in new issue
Block a user