Created most of the fluid can code including render

This commit is contained in:
DarkGuardsman 2013-11-27 09:39:37 -05:00
parent 3ffe18367b
commit b77ee71fdf
9 changed files with 273 additions and 11 deletions

BIN
models/FluidCan.tcn Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 302 B

View file

@ -5,6 +5,7 @@ import java.awt.Color;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.client.MinecraftForgeClient;
import universalelectricity.core.vector.Vector3;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.client.registry.RenderingRegistry;
@ -12,8 +13,10 @@ import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import dark.core.client.renders.BlockRenderingHandler;
import dark.core.client.renders.ItemRenderFluidCan;
import dark.core.client.renders.RenderTestCar;
import dark.core.common.CommonProxy;
import dark.core.common.CoreRecipeLoader;
import dark.core.prefab.ModPrefab;
import dark.core.prefab.vehicles.EntityTestCar;
@ -22,7 +25,7 @@ public class ClientProxy extends CommonProxy
{
/** Renders a laser beam from one power to another by a set color for a set time
*
*
* @param world - world this laser is to be rendered in
* @param position - start vector3
* @param target - end vector3
@ -40,11 +43,17 @@ public class ClientProxy extends CommonProxy
@Override
public void preInit()
{
RenderingRegistry.registerBlockHandler(new BlockRenderingHandler());
//MinecraftForge.EVENT_BUS.register(SoundHandler.INSTANCE);
RenderingRegistry.registerEntityRenderingHandler(EntityTestCar.class, new RenderTestCar());
}
@Override
public void init()
{
RenderingRegistry.registerBlockHandler(new BlockRenderingHandler());
if (CoreRecipeLoader.itemFluidCan != null)
MinecraftForgeClient.registerItemRenderer(CoreRecipeLoader.itemFluidCan.itemID, new ItemRenderFluidCan());
}
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
{

View file

@ -0,0 +1,130 @@
// Date: 11/27/2013 9:27:04 AM
// Template version 1.1
// Java generated by Techne
// Keep in mind that you still need to fill in some blanks
// - ZeuX
package dark.core.client.models;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
public class ModelSmallFluidCan extends ModelBase
{
//fields
ModelRenderer body1;
ModelRenderer body2;
ModelRenderer body3;
ModelRenderer body4;
ModelRenderer edge1;
ModelRenderer edge2;
ModelRenderer edge3;
ModelRenderer edge4;
ModelRenderer glass1;
ModelRenderer glass2;
ModelRenderer glass3;
ModelRenderer glass4;
public ModelSmallFluidCan()
{
textureWidth = 64;
textureHeight = 32;
body1 = new ModelRenderer(this, 12, 28);
body1.addBox(-1.5F, 0F, -1.5F, 3, 1, 3);
body1.setRotationPoint(0F, 23F, 0F);
body1.setTextureSize(64, 32);
body1.mirror = true;
setRotation(body1, 0F, 0F, 0F);
body2 = new ModelRenderer(this, 10, 22);
body2.addBox(-2F, -1F, -2F, 4, 1, 4);
body2.setRotationPoint(0F, 23F, 0F);
body2.setTextureSize(64, 32);
body2.mirror = true;
setRotation(body2, 0F, 0F, 0F);
body3 = new ModelRenderer(this, 10, 5);
body3.addBox(-2F, -1F, -2F, 4, 1, 4);
body3.setRotationPoint(0F, 17F, 0F);
body3.setTextureSize(64, 32);
body3.mirror = true;
setRotation(body3, 0F, 0F, 0F);
body4 = new ModelRenderer(this, 12, 0);
body4.addBox(-1.5F, 0F, -1.5F, 3, 1, 3);
body4.setRotationPoint(0F, 15F, 0F);
body4.setTextureSize(64, 32);
body4.mirror = true;
setRotation(body4, 0F, 0F, 0F);
edge1 = new ModelRenderer(this, 21, 13);
edge1.addBox(-1.9F, -1F, -1.9F, 1, 5, 1);
edge1.setRotationPoint(0F, 18F, 0F);
edge1.setTextureSize(64, 32);
edge1.mirror = true;
setRotation(edge1, 0F, 0F, 0F);
edge2 = new ModelRenderer(this, 26, 13);
edge2.addBox(-2.1F, -1F, -1.9F, 1, 5, 1);
edge2.setRotationPoint(3F, 18F, 0F);
edge2.setTextureSize(64, 32);
edge2.mirror = true;
setRotation(edge2, 0F, 0F, 0F);
edge3 = new ModelRenderer(this, 10, 13);
edge3.addBox(-2.1F, -1F, 0.9F, 1, 5, 1);
edge3.setRotationPoint(3F, 18F, 0F);
edge3.setTextureSize(64, 32);
edge3.mirror = true;
setRotation(edge3, 0F, 0F, 0F);
edge4 = new ModelRenderer(this, 16, 13);
edge4.addBox(-1.9F, -1F, 0.9F, 1, 5, 1);
edge4.setRotationPoint(0F, 18F, 0F);
edge4.setTextureSize(64, 32);
edge4.mirror = true;
setRotation(edge4, 0F, 0F, 0F);
glass1 = new ModelRenderer(this, 2, 13);
glass1.addBox(-3.1F, -1F, 1.8F, 2, 5, 0);
glass1.setRotationPoint(2F, 18F, 0F);
glass1.setTextureSize(64, 32);
glass1.mirror = true;
setRotation(glass1, 0F, 0F, 0F);
glass2 = new ModelRenderer(this, 2, 13);
glass2.addBox(-3.1F, -1F, 0.2F, 2, 5, 0);
glass2.setRotationPoint(2F, 18F, -2F);
glass2.setTextureSize(64, 32);
glass2.mirror = true;
setRotation(glass2, 0F, 0F, 0F);
glass3 = new ModelRenderer(this, 2, 13);
glass3.addBox(-1.1F, -1F, -0.2F, 2, 5, 0);
glass3.setRotationPoint(2F, 18F, 0F);
glass3.setTextureSize(64, 32);
glass3.mirror = true;
setRotation(glass3, 0F, 1.570796F, 0F);
glass4 = new ModelRenderer(this, 2, 13);
glass4.addBox(-1.1F, -1F, 2.2F, 2, 5, 0);
glass4.setRotationPoint(-4F, 18F, 0F);
glass4.setTextureSize(64, 32);
glass4.mirror = true;
setRotation(glass4, 0F, 1.570796F, 0F);
}
public void render(float f5)
{
body1.render(f5);
body2.render(f5);
body3.render(f5);
body4.render(f5);
edge1.render(f5);
edge2.render(f5);
edge3.render(f5);
edge4.render(f5);
glass1.render(f5);
glass2.render(f5);
glass3.render(f5);
glass4.render(f5);
}
private void setRotation(ModelRenderer model, float x, float y, float z)
{
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
}

View file

@ -36,7 +36,7 @@ public class BlockRenderingHandler implements ISimpleBlockRenderingHandler
GL11.glRotatef(180f, 0f, 0f, 1f);
solarPanelModel.render(0.0625F);
}
else if (CoreRecipeLoader.basicMachine != null && block.blockID == CoreRecipeLoader.basicMachine.blockID)
else if (CoreRecipeLoader.blockSteamGen != null && block.blockID == CoreRecipeLoader.blockSteamGen.blockID)
{
ModelMachine model = RenderSteamGen.getModel(metadata);
FMLClientHandler.instance().getClient().renderEngine.bindTexture(RenderSteamGen.getTexture(metadata));

View file

@ -0,0 +1,57 @@
package dark.core.client.renders;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.IItemRenderer;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import dark.core.client.models.ModelSmallFluidCan;
import dark.core.common.CoreRecipeLoader;
import dark.core.common.DarkMain;
@SideOnly(Side.CLIENT)
public class ItemRenderFluidCan implements IItemRenderer
{
public static final ModelSmallFluidCan CAN_MODEL = new ModelSmallFluidCan();
public static final ResourceLocation CAN_TEXTURE = new ResourceLocation(DarkMain.getInstance().DOMAIN, DarkMain.MODEL_DIRECTORY + "FluidCanA.png");
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type)
{
return true;
}
@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper)
{
return true;
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data)
{
if (CoreRecipeLoader.itemFluidCan != null && item.itemID == CoreRecipeLoader.itemFluidCan.itemID)
{
GL11.glPushMatrix();
FMLClientHandler.instance().getClient().renderEngine.bindTexture(CAN_TEXTURE);
if (type != ItemRenderType.EQUIPPED)
{
GL11.glTranslatef(0.5F, -0.5F, 0.5F);
}
else
{
GL11.glTranslatef(0.5F, -0.5F, 0.5F);
}
CAN_MODEL.render(0.0625F);
GL11.glPopMatrix();
}
}
}

View file

@ -34,7 +34,7 @@ public class CoreRecipeLoader extends RecipeLoader
public static Block blockColorSand;
public static Block blockBasalt;
public static Block blockGlowGlass;
public static Block basicMachine, blockSolar;
public static Block blockSteamGen, blockSolar;
public static Block blockGas;
/* ITEMS */
@ -47,6 +47,7 @@ public class CoreRecipeLoader extends RecipeLoader
public static Item itemGlowingSand;
public static Item itemDiggingTool;
public static Item itemVehicleTest;
public static Item itemFluidCan;
public static boolean debugOreItems = false;
@Override

View file

@ -49,6 +49,7 @@ import dark.core.common.items.EnumOrePart;
import dark.core.common.items.ItemBattery;
import dark.core.common.items.ItemColoredDust;
import dark.core.common.items.ItemCommonTool;
import dark.core.common.items.ItemFluidCan;
import dark.core.common.items.ItemOreDirv;
import dark.core.common.items.ItemParts;
import dark.core.common.items.ItemParts.Parts;
@ -268,7 +269,7 @@ public class DarkMain extends ModPrefab
{
blockMulti = (BlockMulti) m;
}
CoreRecipeLoader.basicMachine = ModObjectRegistry.createNewBlock("DMBlockBasicMachine", DarkMain.MOD_ID, BlockSmallSteamGen.class, ItemBlockHolder.class);
CoreRecipeLoader.blockSteamGen = ModObjectRegistry.createNewBlock("DMBlockSteamMachine", DarkMain.MOD_ID, BlockSmallSteamGen.class, ItemBlockHolder.class);
CoreRecipeLoader.blockOre = ModObjectRegistry.createNewBlock("DMBlockOre", DarkMain.MOD_ID, BlockOre.class, ItemBlockOre.class);
CoreRecipeLoader.blockWire = ModObjectRegistry.createNewBlock("DMBlockWire", DarkMain.MOD_ID, BlockWire.class, ItemBlockWire.class);
CoreRecipeLoader.blockDebug = ModObjectRegistry.createNewBlock("DMBlockDebug", DarkMain.MOD_ID, BlockDebug.class, ItemBlockHolder.class);
@ -288,6 +289,8 @@ public class DarkMain extends ModPrefab
CoreRecipeLoader.itemGlowingSand = ModObjectRegistry.createNewItem("DMItemGlowingSand", DarkMain.MOD_ID, ItemColoredDust.class, true);
CoreRecipeLoader.itemDiggingTool = ModObjectRegistry.createNewItem("ItemDiggingTools", DarkMain.MOD_ID, ItemCommonTool.class, true);
CoreRecipeLoader.itemVehicleTest = ModObjectRegistry.createNewItem("ItemVehicleTest", DarkMain.MOD_ID, ItemVehicleSpawn.class, true);
CoreRecipeLoader.itemFluidCan = ModObjectRegistry.createNewItem("ItemFluidCan", DarkMain.MOD_ID, ItemFluidCan.class, true);
CONFIGURATION.save();
}

View file

@ -1,17 +1,28 @@
package dark.core.common.items;
import net.minecraft.item.Item;
import java.util.List;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraft.util.StatCollector;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.ItemFluidContainer;
import universalelectricity.core.item.ElectricItemHelper;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import dark.core.common.DMCreativeTab;
import dark.core.common.DarkMain;
import dark.core.prefab.ModPrefab;
/** Small fluid can that is designed to store up to one bucket of fluid.
*
/** Small fluid can that is designed to store up to one bucket of fluid. Doesn't work like a bucket
* as it is sealed with a pressure cap. This can is designed to work with tools or machines only.
*
* @author DarkGuardsman */
public class ItemFluidCan extends Item
public class ItemFluidCan extends ItemFluidContainer
{
public static final String FLUID_NBT = "FluidStack";
@ -21,6 +32,57 @@ public class ItemFluidCan extends Item
public ItemFluidCan()
{
super(DarkMain.CONFIGURATION.getItem("FluidCan", ModPrefab.getNextItemId()).getInt());
this.setCreativeTab(DMCreativeTab.tabIndustrial);
this.setCreativeTab(DMCreativeTab.tabHydrualic);
this.setMaxStackSize(1);
this.setMaxDamage(100);
this.setNoRepair();
this.capacity = FluidContainerRegistry.BUCKET_VOLUME * 2;
this.setContainerItem(this);
}
@Override
public boolean doesContainerItemLeaveCraftingGrid(ItemStack par1ItemStack)
{
FluidStack fluidStack = this.drain(par1ItemStack, Integer.MAX_VALUE, false);
if (fluidStack != null)
{
return false;
}
return true;
}
@Override
public String getItemDisplayName(ItemStack par1ItemStack)
{
String fluid = "";
FluidStack fluidStack = this.drain(par1ItemStack, Integer.MAX_VALUE, false);
if (fluidStack != null)
{
fluid = fluidStack.getFluid().getLocalizedName();
}
return ("" + (fluid + " " + StatCollector.translateToLocal(this.getUnlocalizedNameInefficiently(par1ItemStack) + ".name"))).trim();
}
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
FluidStack fluidStack = this.drain(par1ItemStack, Integer.MAX_VALUE, false);
if (fluidStack != null)
{
par3List.add("Volume: " + fluidStack.amount + "mb");
}
}
@Override
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)
{
par3List.add(ElectricItemHelper.getUncharged(new ItemStack(this)));
ItemStack waterCan = new ItemStack(this);
this.fill(waterCan, new FluidStack(FluidRegistry.WATER, FluidContainerRegistry.BUCKET_VOLUME), true);
par3List.add(waterCan);
ItemStack lavaCan = new ItemStack(this);
this.fill(lavaCan, new FluidStack(FluidRegistry.LAVA, FluidContainerRegistry.BUCKET_VOLUME), true);
par3List.add(lavaCan);
}
}