mirror of
https://github.com/GTNewHorizons/IguanaTweaksTConstruct.git
synced 2026-11-26 06:43:05 +00:00
After a lot of work, MobHeads are back! At least the items themselves + rendering.
This commit is contained in:
1 parent
a35def7b5a
commit
ee6448b65d
12 files changed
+392
-13
No files matched your search
@@ -15,6 +15,7 @@ import iguanaman.iguanatweakstconstruct.leveling.IguanaToolLeveling;
|
||||
import iguanaman.iguanatweakstconstruct.leveling.commands.IguanaCommandLevelUpTool;
|
||||
import iguanaman.iguanatweakstconstruct.leveling.commands.IguanaCommandToolXP;
|
||||
import iguanaman.iguanatweakstconstruct.leveling.commands.debug;
|
||||
import iguanaman.iguanatweakstconstruct.mobheads.IguanaMobHeads;
|
||||
import iguanaman.iguanatweakstconstruct.proxy.CommonProxy;
|
||||
import iguanaman.iguanatweakstconstruct.reference.Config;
|
||||
import iguanaman.iguanatweakstconstruct.reference.Reference;
|
||||
@@ -87,6 +88,7 @@ public class IguanaTweaksTConstruct {
|
||||
pulsar.registerPulse(new IguanaHarvestLevelTweaks());
|
||||
pulsar.registerPulse(new IguanaToolLeveling());
|
||||
pulsar.registerPulse(new IguanaToolPartReplacing());
|
||||
pulsar.registerPulse(new IguanaMobHeads());
|
||||
pulsar.registerPulse(new IguanaItems());
|
||||
pulsar.registerPulse(new IguanaTweaks());
|
||||
pulsar.preInit(event);
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package iguanaman.iguanatweakstconstruct.mobheads;
|
||||
|
||||
import cpw.mods.fml.common.SidedProxy;
|
||||
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.items.IguanaSkull;
|
||||
import iguanaman.iguanatweakstconstruct.mobheads.proxy.MobHeadCommonProxy;
|
||||
import iguanaman.iguanatweakstconstruct.mobheads.renderers.RenderPlayerHandler;
|
||||
import iguanaman.iguanatweakstconstruct.mobheads.tileentities.IguanaSkullTileEntity;
|
||||
import iguanaman.iguanatweakstconstruct.reference.Reference;
|
||||
import mantle.pulsar.pulse.Handler;
|
||||
import mantle.pulsar.pulse.Pulse;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
/**
|
||||
* Adds additional MobHeads and controls MobHead dropping.
|
||||
*/
|
||||
@Pulse(id = Reference.PULSE_MOBHEADS, description = "Adds additional MobHeads and control over MobHead drops.")
|
||||
public class IguanaMobHeads {
|
||||
public static Item skullItem;
|
||||
public static Block skullBlock;
|
||||
|
||||
@SidedProxy(clientSide = "iguanaman.iguanatweakstconstruct.mobheads.proxy.MobHeadClientProxy", serverSide = "iguanaman.iguanatweakstconstruct.mobheads.proxy.MobHeadCommonProxy")
|
||||
public static MobHeadCommonProxy proxy;
|
||||
|
||||
@Handler
|
||||
public void preInit(FMLPreInitializationEvent event)
|
||||
{
|
||||
proxy.initialize();
|
||||
|
||||
skullItem = new IguanaSkull();
|
||||
GameRegistry.registerItem(skullItem, "SkullItem");
|
||||
|
||||
skullBlock = new IguanaSkullBlock().setHardness(1.0F).setStepSound(Block.soundTypeSand).setBlockName("skullItem").setBlockTextureName("skullItem");
|
||||
GameRegistry.registerBlock(skullBlock, "SkullBlock");
|
||||
GameRegistry.registerTileEntity(IguanaSkullTileEntity.class, "SkullEntity");
|
||||
}
|
||||
|
||||
@Handler
|
||||
public void postInit(FMLPostInitializationEvent event)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.register(new RenderPlayerHandler());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package iguanaman.iguanatweakstconstruct.mobheads.blocks;
|
||||
|
||||
import iguanaman.iguanatweakstconstruct.mobheads.tileentities.IguanaSkullTileEntity;
|
||||
import net.minecraft.block.BlockSkull;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class IguanaSkullBlock extends BlockSkull {
|
||||
|
||||
public IguanaSkullBlock() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new instance of a block's tile entity class. Called on placing the block.
|
||||
*/
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int metadata)
|
||||
{
|
||||
return new IguanaSkullTileEntity();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
package iguanaman.iguanatweakstconstruct.mobheads.items;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import iguanaman.iguanatweakstconstruct.mobheads.IguanaMobHeads;
|
||||
import iguanaman.iguanatweakstconstruct.reference.Reference;
|
||||
import net.minecraft.block.BlockSkull;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntitySkull;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
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;
|
||||
|
||||
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"};
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon field_94586_c [];
|
||||
|
||||
public IguanaSkull() {
|
||||
super();
|
||||
this.setContainerItem(Items.skull);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the unlocalized name of this item. This version accepts an ItemStack so different stacks can have
|
||||
* different names based on their damage or NBT.
|
||||
*/
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack par1ItemStack)
|
||||
{
|
||||
int i = par1ItemStack.getItemDamage();
|
||||
|
||||
if (i < 0 || i >= skullTypes.length)
|
||||
i = 0;
|
||||
|
||||
return Reference.resource(field_94587_a[i]);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a list of items with the same ID, but different meta (eg: dye returns 16 items)
|
||||
*/
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
@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));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an icon index based on an item's damage value
|
||||
*/
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIconFromDamage(int par1)
|
||||
{
|
||||
if (par1 < 0 || par1 >= skullTypes.length)
|
||||
par1 = 0;
|
||||
|
||||
return field_94586_c[par1];
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister par1IconRegister)
|
||||
{
|
||||
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]));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidArmor(ItemStack stack, int armorType, Entity entity) {
|
||||
return armorType == 0; // 0 = helmet
|
||||
}
|
||||
|
||||
|
||||
// copy'n'paste of the ItemSkull method, but places our own skull instead of the vanilla one
|
||||
public boolean onItemUse(ItemStack p_77648_1_, EntityPlayer p_77648_2_, World p_77648_3_, int p_77648_4_, int p_77648_5_, int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_) {
|
||||
if (p_77648_7_ == 0) {
|
||||
return false;
|
||||
} else if (!p_77648_3_.getBlock(p_77648_4_, p_77648_5_, p_77648_6_).getMaterial().isSolid()) {
|
||||
return false;
|
||||
} else {
|
||||
if (p_77648_7_ == 1) {
|
||||
++p_77648_5_;
|
||||
}
|
||||
|
||||
if (p_77648_7_ == 2) {
|
||||
--p_77648_6_;
|
||||
}
|
||||
|
||||
if (p_77648_7_ == 3) {
|
||||
++p_77648_6_;
|
||||
}
|
||||
|
||||
if (p_77648_7_ == 4) {
|
||||
--p_77648_4_;
|
||||
}
|
||||
|
||||
if (p_77648_7_ == 5) {
|
||||
++p_77648_4_;
|
||||
}
|
||||
|
||||
if (!p_77648_3_.isRemote) {
|
||||
p_77648_3_.setBlock(p_77648_4_, p_77648_5_, p_77648_6_, IguanaMobHeads.skullBlock, p_77648_7_, 2);
|
||||
int i1 = 0;
|
||||
|
||||
if (p_77648_7_ == 1) {
|
||||
i1 = MathHelper.floor_double((double) (p_77648_2_.rotationYaw * 16.0F / 360.0F) + 0.5D) & 15;
|
||||
}
|
||||
|
||||
TileEntity tileentity = p_77648_3_.getTileEntity(p_77648_4_, p_77648_5_, p_77648_6_);
|
||||
|
||||
if (tileentity != null && tileentity instanceof TileEntitySkull) {
|
||||
|
||||
((TileEntitySkull) tileentity).func_152107_a(p_77648_1_.getItemDamage());
|
||||
|
||||
((TileEntitySkull) tileentity).func_145903_a(i1);
|
||||
((BlockSkull) IguanaMobHeads.skullBlock).func_149965_a(p_77648_3_, p_77648_4_, p_77648_5_, p_77648_6_, (TileEntitySkull) tileentity);
|
||||
}
|
||||
|
||||
--p_77648_1_.stackSize;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package iguanaman.iguanatweakstconstruct.mobheads.proxy;
|
||||
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
import iguanaman.iguanatweakstconstruct.mobheads.renderers.IguanaTileEntitySkullRenderer;
|
||||
import iguanaman.iguanatweakstconstruct.mobheads.tileentities.IguanaSkullTileEntity;
|
||||
|
||||
public class MobHeadClientProxy extends MobHeadCommonProxy {
|
||||
@Override
|
||||
public void initialize() {
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(IguanaSkullTileEntity.class, IguanaTileEntitySkullRenderer.renderer);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package iguanaman.iguanatweakstconstruct.mobheads.proxy;
|
||||
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class MobHeadCommonProxy {
|
||||
|
||||
public void initialize() {}
|
||||
}
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
package iguanaman.iguanatweakstconstruct.mobheads.renderers;
|
||||
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||
import net.minecraft.client.model.ModelSkeletonHead;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySkullRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntitySkull;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class IguanaTileEntitySkullRenderer extends TileEntitySpecialRenderer {
|
||||
public static IguanaTileEntitySkullRenderer renderer = new IguanaTileEntitySkullRenderer();
|
||||
|
||||
private ModelSkeletonHead modelSkull = new ModelSkeletonHead(0,0,64,32); // standard skull model
|
||||
private ModelSkeletonHead modelZombie = new ModelSkeletonHead(0,0,64,64); // zombie skull model
|
||||
|
||||
private ResourceLocation[] textures = new ResourceLocation[] {
|
||||
new ResourceLocation("textures/entity/enderman/enderman.png"),
|
||||
new ResourceLocation("textures/entity/zombie_pigman.png"),
|
||||
new ResourceLocation("textures/entity/blaze.png")
|
||||
};
|
||||
|
||||
public IguanaTileEntitySkullRenderer()
|
||||
{
|
||||
this.func_147497_a(TileEntityRendererDispatcher.instance);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity entity, double x, double y, double z, float f) {
|
||||
if(!(entity instanceof TileEntitySkull))
|
||||
return;
|
||||
TileEntitySkull entitySkull = (TileEntitySkull)entity;
|
||||
|
||||
float r = (entitySkull.func_145906_b() * 360) / 16.0F;
|
||||
renderSkull((float)x, (float)y, (float)z, r, entitySkull.getBlockMetadata(), entitySkull.func_145904_a());
|
||||
}
|
||||
|
||||
public void renderSkull(float x, float y, float z, float r, int sidePlacement, int meta)
|
||||
{
|
||||
ModelSkeletonHead model = modelSkull;
|
||||
// chose model
|
||||
if(meta == 1)
|
||||
model = modelZombie;
|
||||
|
||||
// chose texture
|
||||
this.bindTexture(textures[meta]);
|
||||
|
||||
|
||||
// begin rendering
|
||||
GL11.glPushMatrix();
|
||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
||||
|
||||
|
||||
if (sidePlacement != 1)
|
||||
{
|
||||
switch (sidePlacement)
|
||||
{
|
||||
case 2:
|
||||
GL11.glTranslatef(x + 0.5F, y + 0.25F, z + 0.74F);
|
||||
break;
|
||||
case 3:
|
||||
GL11.glTranslatef(x + 0.5F, y + 0.25F, z + 0.26F);
|
||||
r = 180.0F;
|
||||
break;
|
||||
case 4:
|
||||
GL11.glTranslatef(x + 0.74F, y + 0.25F, z + 0.5F);
|
||||
r = 270.0F;
|
||||
break;
|
||||
case 5:
|
||||
default:
|
||||
GL11.glTranslatef(x + 0.26F, y + 0.25F, z + 0.5F);
|
||||
r = 90.0F;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GL11.glTranslatef(x + 0.5F, y, z + 0.5F);
|
||||
}
|
||||
|
||||
|
||||
float f4 = 0.0625F;
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
GL11.glScalef(-1.0F, -1.0F, 1.0F);
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
|
||||
model.render(null, 0.0f, 0.0f, 0.0f, r, 0.0f, f4);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package iguanaman.iguanatweakstconstruct.mobheads.renderers;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import iguanaman.iguanatweakstconstruct.mobheads.IguanaMobHeads;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.client.event.RenderPlayerEvent;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class RenderPlayerHandler {
|
||||
@SubscribeEvent
|
||||
public void renderSkullHelmet(RenderPlayerEvent.SetArmorModel event)
|
||||
{
|
||||
ItemStack itemStack = event.entityPlayer.inventory.armorItemInSlot(3);
|
||||
if(itemStack == null || itemStack.getItem() != IguanaMobHeads.skullItem)
|
||||
return;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
event.renderer.modelBipedMain.bipedHead.postRender(0.0625F);
|
||||
float f1 = 1.0625F;
|
||||
GL11.glScalef(f1, -f1, -f1);
|
||||
IguanaTileEntitySkullRenderer.renderer.renderSkull(-0.5f, 0.0f, -0.5f, 180.0f, 1, itemStack.getItemDamage());
|
||||
//TileEntitySkullRenderer.field_147536_b.func_152674_a(-0.5F, 0.0F, -0.5F, 1, 00.0F, 0, null);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package iguanaman.iguanatweakstconstruct.mobheads.tileentities;
|
||||
|
||||
import net.minecraft.tileentity.TileEntitySkull;
|
||||
|
||||
public class IguanaSkullTileEntity extends TileEntitySkull {
|
||||
|
||||
public IguanaSkullTileEntity() {}
|
||||
|
||||
}
|
||||
@@ -36,11 +36,11 @@ public class IguanaBlocks {
|
||||
|
||||
|
||||
//SKULLS
|
||||
Log.info("Adding skull blocks");
|
||||
Log.info("Adding skullItem blocks");
|
||||
// TODO: Find a way to change vanilla skulls
|
||||
/*Blocks.skull = null;
|
||||
newSkullBlock = new IguanaBlockSkull().setHardness(1.0F).setStepSound(Block.soundTypeSand).setBlockName("skull").setBlockTextureName("skull");
|
||||
Blocks.skull = newSkullBlock;
|
||||
/*Blocks.skullItem = null;
|
||||
newSkullBlock = new IguanaBlockSkull().setHardness(1.0F).setStepSound(Block.soundTypeSand).setBlockName("skullItem").setBlockTextureName("skullItem");
|
||||
Blocks.skullItem = newSkullBlock;
|
||||
GameRegistry.registerBlock(newSkullBlock, "Skull");
|
||||
GameRegistry.registerTileEntity(IguanaTileEntitySkull.class, "SkullEntity");*/
|
||||
|
||||
|
||||
@@ -115,13 +115,13 @@ public class IguanaItems {
|
||||
ToolBuilder.addCustomToolRecipe(new BowRecipe(TinkerTools.toolRod, TinkerTools.bowstring, TinkerTools.toolRod, TinkerTools.shortbow));
|
||||
|
||||
//SKULL ITEM
|
||||
Log.info("Adding skull item");
|
||||
// TODO: find a way to replace vanilla skull
|
||||
/*Item.itemsList[Item.skull.itemID] = null;
|
||||
Item.skull = new IguanaItemSkull(141).setUnlocalizedName("skull").setTextureName("skull");
|
||||
LanguageRegistry.addName(new ItemStack(Item.skull, 1, 5), "Enderman Head");
|
||||
LanguageRegistry.addName(new ItemStack(Item.skull, 1, 6), "Zombie Pigman Head");
|
||||
LanguageRegistry.addName(new ItemStack(Item.skull, 1, 7), "Blaze Head");*/
|
||||
Log.info("Adding skullItem item");
|
||||
// TODO: find a way to replace vanilla skullItem
|
||||
/*Item.itemsList[Item.skullItem.itemID] = null;
|
||||
Item.skullItem = new IguanaItemSkull(141).setUnlocalizedName("skullItem").setTextureName("skullItem");
|
||||
LanguageRegistry.addName(new ItemStack(Item.skullItem, 1, 5), "Enderman Head");
|
||||
LanguageRegistry.addName(new ItemStack(Item.skullItem, 1, 6), "Zombie Pigman Head");
|
||||
LanguageRegistry.addName(new ItemStack(Item.skullItem, 1, 7), "Blaze Head");*/
|
||||
|
||||
|
||||
//COBALT ARMOR
|
||||
|
||||
@@ -63,9 +63,9 @@ public class ModifierTweaks
|
||||
if (IguanaConfig.partReplacement)
|
||||
ModifyBuilder.registerModifier(new IguanaModUpgrade());
|
||||
ModifyBuilder.registerModifier(new IguanaModRepair());
|
||||
// TODO: Find a way to replace vanilla skull
|
||||
// TODO: Find a way to replace vanilla skullItem
|
||||
/*if (!IguanaIguanaConfig.toolLevelingRandomBonuses)
|
||||
ModifyBuilder.registerModifier(new ModExtraModifier(new ItemStack[] { new ItemStack(Items.sk, 1, 6), new ItemStack(Item.skull, 1, 7) }, "Tier2Free"));*/
|
||||
ModifyBuilder.registerModifier(new ModExtraModifier(new ItemStack[] { new ItemStack(Items.sk, 1, 6), new ItemStack(Item.skullItem, 1, 7) }, "Tier2Free"));*/
|
||||
ModifyBuilder.registerModifier(new ModInteger(new ItemStack[] { new ItemStack(TinkerTools.materials, 1, 6) }, 4, "Moss", IguanaConfig.mossRepairSpeed, "\u00a72", "Auto-Repair"));
|
||||
ModifyBuilder.registerModifier(new ModDurability(new ItemStack[] { new ItemStack(Items.emerald) }, 1, 0, 0.5f, TConstructRegistry.getMaterial("Bronze").harvestLevel(), "Emerald",
|
||||
"\u00a72Durability +50%", "\u00a72"));
|
||||
|
||||
Reference in new issue
Block a user