mirror of
https://github.com/GTNewHorizons/IguanaTweaksTConstruct.git
synced 2026-11-26 06:43:05 +00:00
Refactor mob heads to allow easily added optional skulls. Add support for TE blizzes \o/
This commit is contained in:
1 parent
e1807c9a66
commit
af94237e28
6 files changed
+82
-21
No files matched your search
@@ -1,5 +1,6 @@
|
||||
package iguanaman.iguanatweakstconstruct.mobheads;
|
||||
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.SidedProxy;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
@@ -10,7 +11,9 @@ import iguanaman.iguanatweakstconstruct.mobheads.items.IguanaSkull;
|
||||
import iguanaman.iguanatweakstconstruct.mobheads.proxy.MobHeadCommonProxy;
|
||||
import iguanaman.iguanatweakstconstruct.mobheads.handlers.RenderPlayerHandler;
|
||||
import iguanaman.iguanatweakstconstruct.mobheads.tileentities.IguanaSkullTileEntity;
|
||||
import iguanaman.iguanatweakstconstruct.old.blocks.IguanaTileEntitySkull;
|
||||
import iguanaman.iguanatweakstconstruct.reference.Reference;
|
||||
import iguanaman.iguanatweakstconstruct.util.Log;
|
||||
import mantle.pulsar.pulse.Handler;
|
||||
import mantle.pulsar.pulse.Pulse;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -33,12 +36,16 @@ public class IguanaMobHeads {
|
||||
{
|
||||
proxy.initialize();
|
||||
|
||||
if(Loader.isModLoaded("ThermalFoundation"))
|
||||
integrateThermalExpansion();
|
||||
|
||||
skullItem = new IguanaSkull();
|
||||
GameRegistry.registerItem(skullItem, "SkullItem");
|
||||
|
||||
skullBlock = new IguanaSkullBlock().setHardness(1.0F).setStepSound(Block.soundTypeSand).setBlockName("skullItem").setBlockTextureName("skullItem");
|
||||
skullBlock = new IguanaSkullBlock();
|
||||
GameRegistry.registerBlock(skullBlock, "SkullBlock");
|
||||
GameRegistry.registerTileEntity(IguanaSkullTileEntity.class, "SkullEntity");
|
||||
|
||||
}
|
||||
|
||||
@Handler
|
||||
@@ -49,4 +56,10 @@ public class IguanaMobHeads {
|
||||
|
||||
proxy.postInit();
|
||||
}
|
||||
|
||||
private void integrateThermalExpansion()
|
||||
{
|
||||
Log.info("Adding Blizz head");
|
||||
IguanaSkull.addHead(3, "blizz", "skull_blizz");
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package iguanaman.iguanatweakstconstruct.mobheads.blocks;
|
||||
|
||||
import iguanaman.iguanatweakstconstruct.mobheads.tileentities.IguanaSkullTileEntity;
|
||||
import iguanaman.iguanatweakstconstruct.reference.Reference;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockSkull;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
@@ -9,6 +11,11 @@ public class IguanaSkullBlock extends BlockSkull {
|
||||
|
||||
public IguanaSkullBlock() {
|
||||
super();
|
||||
|
||||
this.setHardness(1.0F);
|
||||
this.setStepSound(Block.soundTypeSand);
|
||||
this.setBlockName(Reference.block("skull"));
|
||||
this.setBlockTextureName("skullItem");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,6 +8,7 @@ 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.EntityList;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.monster.*;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -93,6 +94,16 @@ public class MobHeadHandler {
|
||||
skullItem = IguanaMobHeads.skullItem;
|
||||
skullId = IguanaSkull.META_BLAZE;
|
||||
}
|
||||
// mod support
|
||||
else {
|
||||
String mobName = EntityList.getEntityString(mob);
|
||||
// thermal expansion
|
||||
if(mobName.equals("Blizz"))
|
||||
{
|
||||
skullItem = IguanaMobHeads.skullItem;
|
||||
skullId = IguanaSkull.META_BLIZZ;
|
||||
}
|
||||
}
|
||||
|
||||
// no skull found?
|
||||
if(skullItem == null)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package iguanaman.iguanatweakstconstruct.mobheads.items;
|
||||
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import iguanaman.iguanatweakstconstruct.mobheads.IguanaMobHeads;
|
||||
@@ -18,15 +19,42 @@ import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class IguanaSkull extends net.minecraft.item.ItemSkull {
|
||||
public static final int META_ENDERMAN = 0;
|
||||
public static final int META_PIGZOMBIE = 1;
|
||||
public static final int META_BLAZE = 2;
|
||||
public static final int META_BLIZZ = 3;
|
||||
|
||||
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"};
|
||||
// an entry for a head
|
||||
public static class HeadEntry {
|
||||
public String name;
|
||||
public String iconString;
|
||||
public IIcon icon;
|
||||
|
||||
public HeadEntry(String name, String iconString) {
|
||||
this.name = name;
|
||||
this.iconString = iconString;
|
||||
}
|
||||
}
|
||||
|
||||
private static final Map<Integer, HeadEntry> headEntries = new HashMap<Integer, HeadEntry>();
|
||||
// add vanilla heads
|
||||
static {
|
||||
addHead(0, "enderman", "skull_enderman");
|
||||
addHead(1, "pigman", "skull_pigman");
|
||||
addHead(2, "blaze", "skull_blaze");
|
||||
}
|
||||
|
||||
public static void addHead(int meta, String name, String icon) {
|
||||
headEntries.put(meta, new HeadEntry(name, icon));
|
||||
}
|
||||
|
||||
public static boolean isHeadRegistered(int meta) { return headEntries.containsKey(meta); }
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon field_94586_c [];
|
||||
@@ -43,12 +71,11 @@ public class IguanaSkull extends net.minecraft.item.ItemSkull {
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack par1ItemStack)
|
||||
{
|
||||
int i = par1ItemStack.getItemDamage();
|
||||
Integer i = par1ItemStack.getItemDamage();
|
||||
if(!headEntries.containsKey(i))
|
||||
i = 0;
|
||||
|
||||
if (i < 0 || i >= skullTypes.length)
|
||||
i = 0;
|
||||
|
||||
return Reference.resource(field_94587_a[i]);
|
||||
return Reference.item(headEntries.get(i).name);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,8 +86,8 @@ public class IguanaSkull extends net.minecraft.item.ItemSkull {
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List)
|
||||
{
|
||||
for (int j = 0; j < skullTypes.length; ++j)
|
||||
par3List.add(new ItemStack(par1, 1, j));
|
||||
for(Integer meta : headEntries.keySet())
|
||||
par3List.add(new ItemStack(par1, 1, meta));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,22 +95,20 @@ public class IguanaSkull extends net.minecraft.item.ItemSkull {
|
||||
*/
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIconFromDamage(int par1)
|
||||
public IIcon getIconFromDamage(int meta)
|
||||
{
|
||||
if (par1 < 0 || par1 >= skullTypes.length)
|
||||
par1 = 0;
|
||||
if(!headEntries.containsKey(meta))
|
||||
meta = 0;
|
||||
|
||||
return field_94586_c[par1];
|
||||
return headEntries.get(meta).icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister par1IconRegister)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
field_94586_c = new IIcon[field_94587_a.length];
|
||||
|
||||
for (int i = 0; i < field_94587_a.length; ++i)
|
||||
field_94586_c[i] = par1IconRegister.registerIcon(Reference.resource(field_94587_a[i]));
|
||||
for(HeadEntry entry : headEntries.values())
|
||||
entry.icon = iconRegister.registerIcon(Reference.resource(entry.iconString));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+7
-2
@@ -2,6 +2,7 @@ package iguanaman.iguanatweakstconstruct.mobheads.renderers;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import iguanaman.iguanatweakstconstruct.mobheads.items.IguanaSkull;
|
||||
import iguanaman.iguanatweakstconstruct.mobheads.models.ModelBucketHelmet;
|
||||
import iguanaman.iguanatweakstconstruct.mobheads.models.ModelEnderManHead;
|
||||
import iguanaman.iguanatweakstconstruct.mobheads.models.ModelHeadwear;
|
||||
@@ -65,8 +66,12 @@ public class IguanaTileEntitySkullRenderer extends TileEntitySpecialRenderer {
|
||||
renderSkull(x,y,z, r, sidePlacement, modelEnderManHead, textures[0]);
|
||||
else if(meta == 1)
|
||||
renderSkull(x,y,z, r, sidePlacement, modelZombie, textures[1]);
|
||||
else
|
||||
renderSkull(x,y,z, r, sidePlacement, modelSkull, textures[meta]);
|
||||
else {
|
||||
// draw blaze if head doesn't exist (anymore)
|
||||
if(!IguanaSkull.isHeadRegistered(meta))
|
||||
meta = 2;
|
||||
renderSkull(x, y, z, r, sidePlacement, modelSkull, textures[meta]);
|
||||
}
|
||||
}
|
||||
|
||||
public void renderBucket(float x, float y, float z, float r, int sidePlacement, int meta)
|
||||
|
||||
Reference in new issue
Block a user