Skip to content
This repository has been archived by the owner on Mar 10, 2021. It is now read-only.

Commit

Permalink
Yesss. Buckets.
Browse files Browse the repository at this point in the history
  • Loading branch information
bonii-xx committed Aug 1, 2014
1 parent 48d5190 commit edd6c7e
Show file tree
Hide file tree
Showing 9 changed files with 129 additions and 11 deletions.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Expand Up @@ -4,9 +4,11 @@
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.registry.GameRegistry;
import iguanaman.iguanatweakstconstruct.IguanaTweaksTConstruct;
import iguanaman.iguanatweakstconstruct.claybuckets.items.ClayBucket;
import iguanaman.iguanatweakstconstruct.claybuckets.items.ClayBucketMilk;
import iguanaman.iguanatweakstconstruct.claybuckets.items.ClayBucketTinkerLiquids;
import iguanaman.iguanatweakstconstruct.claybuckets.items.WearableBucket;
import iguanaman.iguanatweakstconstruct.reference.Reference;
import iguanaman.iguanatweakstconstruct.util.Log;
import mantle.pulsar.pulse.Handler;
Expand Down Expand Up @@ -37,6 +39,8 @@ public class IguanaItems {
public static Item clayBucketMilk;
public static Item clayBucketsTinkers;

public static Item wearableBuckets;

@Handler
public void preInit(FMLPreInitializationEvent event)
{
Expand All @@ -58,6 +62,12 @@ public void preInit(FMLPreInitializationEvent event)
GameRegistry.registerItem(clayBucketMilk, "clayBucketMilk");
GameRegistry.registerItem(clayBucketsTinkers, "clayBucketsTinkers");

// secrit bucketssss
if(IguanaTweaksTConstruct.isMobHeadsActive) {
wearableBuckets = new WearableBucket();
GameRegistry.registerItem(wearableBuckets, "wearableBucket");
}

// register milkbucket to the ordictionary
OreDictionary.registerOre("listAllmilk", clayBucketMilk); // i suppose this is for pams harvestcraft.

Expand Down
@@ -0,0 +1,72 @@
package iguanaman.iguanatweakstconstruct.claybuckets.items;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import iguanaman.iguanatweakstconstruct.claybuckets.IguanaItems;
import iguanaman.iguanatweakstconstruct.reference.Reference;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;

import java.util.List;

public class WearableBucket extends Item {
private static final String[] textureTypes = new String[] {"bucket_helmet", "enderman_jaw"};
private IIcon[] icons;

public WearableBucket() {
super();
this.setContainerItem(IguanaItems.wearableBuckets);
this.setUnlocalizedName(Reference.MOD_ID + ".wearable_bucket");

this.setMaxStackSize(1);
}

@Override
public boolean isValidArmor(ItemStack stack, int armorType, Entity entity) {
return armorType == 0; // 0 = helmet
}

@Override
public String getUnlocalizedName(ItemStack par1ItemStack)
{
int i = par1ItemStack.getItemDamage();

if (i < 0 || i >= textureTypes.length)
i = 0;

return Reference.resource(textureTypes[i]);
}

@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings({ "unchecked", "rawtypes" })
public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List)
{
for (int j = 0; j < textureTypes.length; ++j)
par3List.add(new ItemStack(par1, 1, j));
}

@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister par1IconRegister)
{
icons = new IIcon[textureTypes.length];

for (int i = 0; i < textureTypes.length; ++i)
icons[i] = par1IconRegister.registerIcon(Reference.resource(textureTypes[i]));
}

@Override
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(int par1)
{
if (par1 < 0 || par1 >= textureTypes.length)
par1 = 0;

return icons[par1];
}
}
Expand Up @@ -44,5 +44,7 @@ public void preInit(FMLPreInitializationEvent event)
public void postInit(FMLPostInitializationEvent event)
{
MinecraftForge.EVENT_BUS.register(new RenderPlayerHandler());

proxy.postInit();
}
}
@@ -1,12 +1,24 @@
package iguanaman.iguanatweakstconstruct.mobheads.proxy;

import cpw.mods.fml.client.registry.ClientRegistry;
import iguanaman.iguanatweakstconstruct.IguanaTweaksTConstruct;
import iguanaman.iguanatweakstconstruct.claybuckets.IguanaItems;
import iguanaman.iguanatweakstconstruct.mobheads.renderers.IguanaTileEntitySkullRenderer;
import iguanaman.iguanatweakstconstruct.mobheads.tileentities.IguanaSkullTileEntity;
import net.minecraft.item.ItemStack;

public class MobHeadClientProxy extends MobHeadCommonProxy {
@Override
public void initialize() {
ClientRegistry.bindTileEntitySpecialRenderer(IguanaSkullTileEntity.class, IguanaTileEntitySkullRenderer.renderer);
}

public void postInit() {
// hide secret stuff ;)
if(IguanaTweaksTConstruct.isItemsActive)
{
codechicken.nei.api.API.hideItem(new ItemStack(IguanaItems.wearableBuckets, 1, 0));
codechicken.nei.api.API.hideItem(new ItemStack(IguanaItems.wearableBuckets, 1, 1));
}
}
}
Expand Up @@ -7,4 +7,6 @@
public class MobHeadCommonProxy {

public void initialize() {}

public void postInit() {}
}
Expand Up @@ -61,16 +61,26 @@ public void renderTileEntityAt(TileEntity entity, double x, double y, double z,

public void renderSkull(float x, float y, float z, float r, int sidePlacement, int meta)
{
ModelBase model = modelSkull;
if(meta == 0)
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]);
}

// chose model
public void renderBucket(float x, float y, float z, float r, int sidePlacement, int meta)
{
if(meta == 0)
model = modelEnderManHead;
if(meta == 1)
model = modelZombie;
renderSkull(x,y,z, r, sidePlacement, modelBucketHelmet, textureBucketHelmet);
else if(meta == 1)
renderSkull(x,y,z, r, sidePlacement, modelEnderManJaw, textures[0]);
}

public void renderSkull(float x, float y, float z, float r, int sidePlacement, ModelBase model, ResourceLocation texture)
{
// chose texture
this.bindTexture(textures[meta]);
this.bindTexture(texture);

// debug
//model = new ModelSkeletonHead(0,16,64,32);
Expand Down Expand Up @@ -115,10 +125,9 @@ public void renderSkull(float x, float y, float z, float r, int sidePlacement, i

model.render(null, 0.0f, 0.0f, 0.0f, r, 0.0f, f4);

// also render endermanstuff!
if(meta == 0)
// also render enderman eyes!
if(model == modelEnderManHead)
{
//modelEnderManJaw.render(null, 0.0f, 0.0f, 0.0f, r, 0.0f, f4);
this.bindTexture(enderManEyes);
model.render(null, 0.0f, 0.0f, 0.0f, r, 0.0f, f4);
}
Expand Down
Expand Up @@ -3,7 +3,10 @@
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import iguanaman.iguanatweakstconstruct.IguanaTweaksTConstruct;
import iguanaman.iguanatweakstconstruct.claybuckets.IguanaItems;
import iguanaman.iguanatweakstconstruct.mobheads.IguanaMobHeads;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.event.RenderPlayerEvent;
import org.lwjgl.opengl.GL11;
Expand All @@ -14,14 +17,22 @@ public class RenderPlayerHandler {
public void renderSkullHelmet(RenderPlayerEvent.SetArmorModel event)
{
ItemStack itemStack = event.entityPlayer.inventory.armorItemInSlot(3);
if(itemStack == null || itemStack.getItem() != IguanaMobHeads.skullItem)
if(itemStack == null)
return;

Item item = itemStack.getItem();
boolean isBucket = IguanaTweaksTConstruct.isItemsActive && item == IguanaItems.wearableBuckets;
if(item != IguanaMobHeads.skullItem && !isBucket)
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());
if(isBucket)
IguanaTileEntitySkullRenderer.renderer.renderBucket(-0.5f, 0.0f, -0.5f, 180.0f, 1, itemStack.getItemDamage());
else
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();
}
Expand Down

0 comments on commit edd6c7e

Please sign in to comment.