Added sink block
simple, nicer looking way of filling buckets, water viels, cleaning color off of armor.
This commit is contained in:
parent
79eb211126
commit
eb923b84db
12 changed files with 523 additions and 31 deletions
|
@ -7,6 +7,7 @@ import liquidmechanics.client.render.RenderGenerator;
|
|||
import liquidmechanics.client.render.RenderPipe;
|
||||
import liquidmechanics.client.render.RenderPump;
|
||||
import liquidmechanics.client.render.RenderReleaseValve;
|
||||
import liquidmechanics.client.render.RenderSink;
|
||||
import liquidmechanics.client.render.RenderTank;
|
||||
import liquidmechanics.common.CommonProxy;
|
||||
import liquidmechanics.common.LiquidMechanics;
|
||||
|
@ -15,6 +16,7 @@ import liquidmechanics.common.tileentity.TileEntityPipe;
|
|||
import liquidmechanics.common.tileentity.TileEntityPump;
|
||||
import liquidmechanics.common.tileentity.TileEntityReleaseValve;
|
||||
import liquidmechanics.common.tileentity.TileEntityRod;
|
||||
import liquidmechanics.common.tileentity.TileEntitySink;
|
||||
import liquidmechanics.common.tileentity.TileEntityTank;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
|
@ -38,6 +40,7 @@ public class ClientProxy extends CommonProxy
|
|||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityGenerator.class, new RenderGenerator());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityTank.class, new RenderTank());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityReleaseValve.class, new RenderReleaseValve());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntitySink.class, new RenderSink());
|
||||
MinecraftForgeClient.registerItemRenderer(LiquidMechanics.blockPipe.blockID, new ItemRenderHelper());
|
||||
MinecraftForgeClient.registerItemRenderer(LiquidMechanics.blockReleaseValve.blockID, new ItemRenderHelper());
|
||||
RenderingRegistry.registerBlockHandler(new BlockRenderHelper());
|
||||
|
|
112
minecraft/liquidmechanics/client/model/ModelSink.java
Normal file
112
minecraft/liquidmechanics/client/model/ModelSink.java
Normal file
|
@ -0,0 +1,112 @@
|
|||
// Date: 1/22/2013 12:21:32 AM
|
||||
// Template version 1.1
|
||||
// Java generated by Techne
|
||||
// Keep in mind that you still need to fill in some blanks
|
||||
// - ZeuX
|
||||
|
||||
package liquidmechanics.client.model;
|
||||
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
import net.minecraft.entity.Entity;
|
||||
|
||||
public class ModelSink extends ModelBase
|
||||
{
|
||||
// fields
|
||||
ModelRenderer Base;
|
||||
ModelRenderer FrontLip;
|
||||
ModelRenderer BottomLip;
|
||||
ModelRenderer RightLip;
|
||||
ModelRenderer LeftLip;
|
||||
ModelRenderer BLip;
|
||||
ModelRenderer Edge;
|
||||
ModelRenderer Edge2;
|
||||
ModelRenderer Water;
|
||||
|
||||
public ModelSink()
|
||||
{
|
||||
textureWidth = 128;
|
||||
textureHeight = 128;
|
||||
|
||||
Base = new ModelRenderer(this, 0, 0);
|
||||
Base.addBox(-7F, 0F, -7F, 14, 12, 14);
|
||||
Base.setRotationPoint(0F, 12F, 0F);
|
||||
Base.setTextureSize(128, 128);
|
||||
Base.mirror = true;
|
||||
setRotation(Base, 0F, 0F, 0F);
|
||||
FrontLip = new ModelRenderer(this, 10, 62);
|
||||
FrontLip.addBox(-8F, -4F, -8F, 16, 4, 2);
|
||||
FrontLip.setRotationPoint(0F, 12F, 0F);
|
||||
FrontLip.setTextureSize(128, 128);
|
||||
FrontLip.mirror = true;
|
||||
setRotation(FrontLip, 0F, 0F, 0F);
|
||||
BottomLip = new ModelRenderer(this, 5, 37);
|
||||
BottomLip.addBox(-8F, -4F, 4F, 16, 4, 4);
|
||||
BottomLip.setRotationPoint(0F, 12F, 0F);
|
||||
BottomLip.setTextureSize(128, 128);
|
||||
BottomLip.mirror = true;
|
||||
setRotation(BottomLip, 0F, 0F, 0F);
|
||||
RightLip = new ModelRenderer(this, 0, 47);
|
||||
RightLip.addBox(-8F, -4F, -6F, 2, 4, 10);
|
||||
RightLip.setRotationPoint(0F, 12F, 0F);
|
||||
RightLip.setTextureSize(128, 128);
|
||||
RightLip.mirror = true;
|
||||
setRotation(RightLip, 0F, 0F, 0F);
|
||||
LeftLip = new ModelRenderer(this, 25, 47);
|
||||
LeftLip.addBox(6F, -4F, -6F, 2, 4, 10);
|
||||
LeftLip.setRotationPoint(0F, 12F, 0F);
|
||||
LeftLip.setTextureSize(128, 128);
|
||||
LeftLip.mirror = true;
|
||||
setRotation(LeftLip, 0F, 0F, 0F);
|
||||
BLip = new ModelRenderer(this, 9, 32);
|
||||
BLip.addBox(-1F, -1F, 4F, 2, 2, 2);
|
||||
BLip.setRotationPoint(0F, 12F, 0F);
|
||||
BLip.setTextureSize(128, 128);
|
||||
BLip.mirror = true;
|
||||
setRotation(BLip, 0.5061455F, 0F, 0F);
|
||||
Edge = new ModelRenderer(this, 5, 64);
|
||||
Edge.addBox(0F, 0F, 0F, 1, 12, 1);
|
||||
Edge.setRotationPoint(7F, 12F, 7F);
|
||||
Edge.setTextureSize(128, 128);
|
||||
Edge.mirror = true;
|
||||
setRotation(Edge, 0F, 0F, 0F);
|
||||
Edge2 = new ModelRenderer(this, 0, 64);
|
||||
Edge2.addBox(0F, 0F, 0F, 1, 12, 1);
|
||||
Edge2.setRotationPoint(-8F, 12F, 7F);
|
||||
Edge2.setTextureSize(128, 128);
|
||||
Edge2.mirror = true;
|
||||
setRotation(Edge2, 0F, 0F, 0F);
|
||||
Water = new ModelRenderer(this, 0, 0);
|
||||
Water.addBox(-6F, 0F, -6F, 12, 0, 10);
|
||||
Water.setRotationPoint(0F, 12F, 0F);
|
||||
Water.setTextureSize(128, 128);
|
||||
Water.mirror = true;
|
||||
setRotation(Water, 0F, 0F, 0F);
|
||||
}
|
||||
|
||||
public void render(float f5)
|
||||
{
|
||||
Base.render(f5);
|
||||
FrontLip.render(f5);
|
||||
BottomLip.render(f5);
|
||||
RightLip.render(f5);
|
||||
LeftLip.render(f5);
|
||||
BLip.render(f5);
|
||||
Edge.render(f5);
|
||||
Edge2.render(f5);
|
||||
|
||||
}
|
||||
|
||||
public void renderLiquid(float f5,float level)
|
||||
{
|
||||
Water.setRotationPoint(0F, 12F - level, 0F);
|
||||
Water.render(f5);
|
||||
}
|
||||
|
||||
private void setRotation(ModelRenderer model, float x, float y, float z)
|
||||
{
|
||||
model.rotateAngleX = x;
|
||||
model.rotateAngleY = y;
|
||||
model.rotateAngleZ = z;
|
||||
}
|
||||
}
|
|
@ -7,6 +7,7 @@ import liquidmechanics.client.model.ModelLargePipe;
|
|||
import liquidmechanics.client.model.ModelLiquidTank;
|
||||
import liquidmechanics.client.model.ModelPump;
|
||||
import liquidmechanics.client.model.ModelReleaseValve;
|
||||
import liquidmechanics.client.model.ModelSink;
|
||||
import liquidmechanics.common.LiquidMechanics;
|
||||
import liquidmechanics.common.tileentity.TileEntityReleaseValve;
|
||||
import net.minecraft.block.Block;
|
||||
|
@ -30,6 +31,7 @@ public class BlockRenderHelper implements ISimpleBlockRenderingHandler
|
|||
private ModelLargePipe SixPipe = new ModelLargePipe();
|
||||
private ModelLiquidTank tank = new ModelLiquidTank();
|
||||
private ModelReleaseValve valve = new ModelReleaseValve();
|
||||
private ModelSink sink = new ModelSink();
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer)
|
||||
|
@ -46,15 +48,24 @@ public class BlockRenderHelper implements ISimpleBlockRenderingHandler
|
|||
modelPump.renderC3(0.0725F);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
if (block.blockID == LiquidMechanics.blockSink.blockID)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float) 0.0F, (float) .8F, (float) 0.0F);
|
||||
GL11.glRotatef(180f, 0f, 0f, 1f);
|
||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, FMLClientHandler.instance().getClient().renderEngine.getTexture(LiquidMechanics.RESOURCE_PATH + "Sink.png"));
|
||||
sink.render(0.0565F);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
if (block.blockID == LiquidMechanics.blockTank.blockID)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float) 0.0F, (float) 1.1F, (float) 0.0F);
|
||||
GL11.glTranslatef((float) 0.0F, (float) 1.0F, (float) 0.0F);
|
||||
GL11.glRotatef(180f, 0f, 0f, 1f);
|
||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, FMLClientHandler.instance().getClient().renderEngine.getTexture(RenderTank.getTankTexture(metadata)));
|
||||
tank.renderMain(0.0625F);
|
||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, FMLClientHandler.instance().getClient().renderEngine.getTexture(RenderTank.getGuageTexture(metadata,4)));
|
||||
tank.renderMeter(null, 0.0625F);
|
||||
tank.renderMeter(null, 0.0565F);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
if (block.blockID == LiquidMechanics.blockRod.blockID)
|
||||
|
@ -69,30 +80,13 @@ public class BlockRenderHelper implements ISimpleBlockRenderingHandler
|
|||
if (block.blockID == LiquidMechanics.blockGenerator.blockID)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float) 0.0F, (float) 1.3F, (float) 0.0F);
|
||||
GL11.glTranslatef((float) 0.0F, (float) 1.0F, (float) 0.0F);
|
||||
GL11.glRotatef(180f, 0f, 0f, 1f);
|
||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, FMLClientHandler.instance().getClient().renderEngine.getTexture(LiquidMechanics.RESOURCE_PATH + "mechanical/Generator.png"));
|
||||
modelGen.render(null);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
public void renderPipeItem(RenderBlocks renderer, int meta)
|
||||
{
|
||||
|
||||
GL11.glPushMatrix();
|
||||
|
||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, FMLClientHandler.instance().getClient().renderEngine.getTexture(RenderPipe.getPipeTexture(meta)));
|
||||
|
||||
GL11.glTranslatef(0.5F, -0.5F, 0.5F);
|
||||
|
||||
SixPipe.renderRight();
|
||||
SixPipe.renderLeft();
|
||||
SixPipe.renderMiddle();
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer)
|
||||
{
|
||||
return false;
|
||||
|
|
74
minecraft/liquidmechanics/client/render/RenderSink.java
Normal file
74
minecraft/liquidmechanics/client/render/RenderSink.java
Normal file
|
@ -0,0 +1,74 @@
|
|||
package liquidmechanics.client.render;
|
||||
|
||||
import liquidmechanics.client.model.ModelSink;
|
||||
import liquidmechanics.common.LiquidMechanics;
|
||||
import liquidmechanics.common.tileentity.TileEntitySink;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.liquids.LiquidContainerRegistry;
|
||||
import net.minecraftforge.liquids.LiquidStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class RenderSink extends TileEntitySpecialRenderer
|
||||
{
|
||||
int type = 0;
|
||||
private ModelSink model;
|
||||
|
||||
public RenderSink()
|
||||
{
|
||||
model = new ModelSink();
|
||||
}
|
||||
|
||||
public void renderWater(LiquidStack stack)
|
||||
{
|
||||
if (stack == null || stack.amount <= 1) { return; }
|
||||
bindTextureByName(LiquidMechanics.RESOURCE_PATH + "blue.png");
|
||||
float p = 0;
|
||||
if(stack.amount > 0)p = 0.5f;
|
||||
if(stack.amount > 500)p=1.5f;
|
||||
if(stack.amount > 1000)p=2.5f;
|
||||
if(stack.amount > 1500)p=3.5f;
|
||||
|
||||
model.renderLiquid(0.0625F, p);
|
||||
}
|
||||
|
||||
public void renderAModelAt(TileEntitySink te, double d, double d1, double d2, float f)
|
||||
{
|
||||
int meta = te.worldObj.getBlockMetadata(te.xCoord, te.yCoord, te.zCoord);
|
||||
|
||||
bindTextureByName(LiquidMechanics.RESOURCE_PATH + "Sink.png");
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F);
|
||||
GL11.glScalef(1.0F, -1F, -1F);
|
||||
switch (meta)
|
||||
{
|
||||
case 3:
|
||||
GL11.glRotatef(90f, 0f, 1f, 0f);
|
||||
break;
|
||||
case 0:
|
||||
GL11.glRotatef(180f, 0f, 1f, 0f);
|
||||
break;
|
||||
case 1:
|
||||
GL11.glRotatef(270f, 0f, 1f, 0f);
|
||||
break;
|
||||
case 2:
|
||||
GL11.glRotatef(0f, 0f, 1f, 0f);
|
||||
break;
|
||||
}
|
||||
model.render(0.0625F);
|
||||
renderWater(te.getStack());
|
||||
GL11.glPopMatrix();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileEntity, double var2, double var4, double var6, float var8)
|
||||
{
|
||||
this.renderAModelAt((TileEntitySink) tileEntity, var2, var4, var6, var8);
|
||||
}
|
||||
|
||||
}
|
|
@ -10,6 +10,7 @@ import liquidmechanics.common.block.BlockPumpMachine;
|
|||
import liquidmechanics.common.block.BlockPipe;
|
||||
import liquidmechanics.common.block.BlockReleaseValve;
|
||||
import liquidmechanics.common.block.BlockRod;
|
||||
import liquidmechanics.common.block.BlockSink;
|
||||
import liquidmechanics.common.block.BlockTank;
|
||||
import liquidmechanics.common.block.BlockWasteLiquid;
|
||||
import liquidmechanics.common.item.ItemGuage;
|
||||
|
@ -24,6 +25,7 @@ import liquidmechanics.common.tileentity.TileEntityPipe;
|
|||
import liquidmechanics.common.tileentity.TileEntityPump;
|
||||
import liquidmechanics.common.tileentity.TileEntityReleaseValve;
|
||||
import liquidmechanics.common.tileentity.TileEntityRod;
|
||||
import liquidmechanics.common.tileentity.TileEntitySink;
|
||||
import liquidmechanics.common.tileentity.TileEntityTank;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
|
@ -60,7 +62,7 @@ import cpw.mods.fml.common.registry.GameRegistry;
|
|||
public class LiquidMechanics extends DummyModContainer
|
||||
{
|
||||
// TODO Change in Version Release
|
||||
public static final String VERSION = "0.2.5";
|
||||
public static final String VERSION = "0.2.6";
|
||||
|
||||
// Constants
|
||||
public static final String NAME = "Liquid Mechanics";
|
||||
|
@ -85,6 +87,7 @@ public class LiquidMechanics extends DummyModContainer
|
|||
public static Block blockRod;
|
||||
public static Block blockGenerator;
|
||||
public static Block blockReleaseValve;
|
||||
public static Block blockSink;
|
||||
|
||||
public static Block blockWasteLiquid;
|
||||
|
||||
|
@ -115,6 +118,7 @@ public class LiquidMechanics extends DummyModContainer
|
|||
blockReleaseValve = new BlockReleaseValve((this.CONFIGURATION.getBlock("Release Valve", BLOCK_ID_PREFIX + 5).getInt()));
|
||||
blockTank = new BlockTank(this.CONFIGURATION.getBlock("Tank", BLOCK_ID_PREFIX + 6).getInt());
|
||||
blockWasteLiquid = new BlockWasteLiquid(this.CONFIGURATION.getBlock("WasteLiquid", BLOCK_ID_PREFIX + 7).getInt());
|
||||
blockSink = new BlockSink(this.CONFIGURATION.getBlock("Sink", BLOCK_ID_PREFIX + 8).getInt());
|
||||
|
||||
// Items
|
||||
itemParts = new ItemParts(this.CONFIGURATION.getItem("Parts", ITEM_ID_PREFIX).getInt());
|
||||
|
@ -135,6 +139,7 @@ public class LiquidMechanics extends DummyModContainer
|
|||
GameRegistry.registerBlock(blockGenerator, "lmGen");
|
||||
GameRegistry.registerBlock(blockMachine, ItemLiquidMachine.class, "lmMachines");
|
||||
GameRegistry.registerBlock(blockTank, ItemTank.class, "lmTank");
|
||||
GameRegistry.registerBlock(blockSink, "lmSink");
|
||||
}
|
||||
|
||||
@Init
|
||||
|
@ -148,6 +153,7 @@ public class LiquidMechanics extends DummyModContainer
|
|||
GameRegistry.registerTileEntity(TileEntityReleaseValve.class, "lmeValve");
|
||||
GameRegistry.registerTileEntity(TileEntityTank.class, "lmTank");
|
||||
GameRegistry.registerTileEntity(TileEntityGenerator.class, "lmGen");
|
||||
GameRegistry.registerTileEntity(TileEntitySink.class,"lmSink");
|
||||
System.out.println("Fluid Mechanics Loaded: " + TranslationHelper.loadLanguages(LANGUAGE_PATH, LANGUAGES_SUPPORTED) + " Languages.");
|
||||
|
||||
}
|
||||
|
@ -167,7 +173,7 @@ public class LiquidMechanics extends DummyModContainer
|
|||
// pipe gauge
|
||||
GameRegistry.addRecipe(new ItemStack(this.itemGauge, 1, 0), new Object[] {
|
||||
"TVT", " T ",
|
||||
'V', new ItemStack(itemParts, 1, 7),
|
||||
'V', new ItemStack(itemParts, 1, Parts.Valve.ordinal()),
|
||||
'T', new ItemStack(itemParts, 1, Parts.Iron.ordinal()) });
|
||||
// iron tube
|
||||
GameRegistry.addRecipe(new ItemStack(itemParts, 4, Parts.Iron.ordinal()), new Object[] {
|
||||
|
|
|
@ -1,24 +1,154 @@
|
|||
package liquidmechanics.common.block;
|
||||
|
||||
import universalelectricity.prefab.tile.TileEntityAdvanced;
|
||||
import liquidmechanics.client.render.BlockRenderHelper;
|
||||
import liquidmechanics.common.MetaGroup;
|
||||
import liquidmechanics.common.TabLiquidMechanics;
|
||||
import liquidmechanics.common.tileentity.TileEntitySink;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.EnumArmorMaterial;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemArmor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldProvider;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.liquids.ILiquidTank;
|
||||
import net.minecraftforge.liquids.LiquidContainerRegistry;
|
||||
import net.minecraftforge.liquids.LiquidStack;
|
||||
|
||||
public class BlockSink extends BlockContainer
|
||||
{
|
||||
|
||||
protected BlockSink(int par1)
|
||||
public BlockSink(int par1)
|
||||
{
|
||||
super(par1, Material.iron);
|
||||
// TODO Auto-generated constructor stub
|
||||
this.setResistance(4f);
|
||||
this.setHardness(4f);
|
||||
this.setBlockName("lmSink");
|
||||
this.setCreativeTab(TabLiquidMechanics.INSTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World var1)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
return new TileEntitySink();
|
||||
}
|
||||
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float sx, float sy, float sz)
|
||||
{
|
||||
ItemStack heldItem = player.inventory.getCurrentItem();
|
||||
TileEntity ent = world.getBlockTileEntity(x, y, z);
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
int grouping = MetaGroup.getGrouping(meta);
|
||||
|
||||
if (heldItem == null || !(ent instanceof TileEntitySink)) { return false; }
|
||||
TileEntitySink sink = (TileEntitySink) ent;
|
||||
|
||||
if (world.isRemote)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
// ItemStack var12 = new ItemStack(Item.potion, 1, 0);heldItem.itemID ==
|
||||
// Item.glassBottle.itemID
|
||||
{
|
||||
ILiquidTank tank = sink.getTanks(ForgeDirection.UNKNOWN)[0];
|
||||
LiquidStack stack = tank.getLiquid();
|
||||
if (grouping == 0 || grouping == 1)
|
||||
{
|
||||
if (heldItem.itemID == Item.bucketWater.itemID)
|
||||
{
|
||||
LiquidStack filling = LiquidContainerRegistry.getLiquidForFilledItem(heldItem);
|
||||
if (stack == null || (stack != null && stack.amount < tank.getCapacity()))
|
||||
{
|
||||
int f = sink.fill(ForgeDirection.getOrientation(side), filling, true);
|
||||
if (f > 0)
|
||||
{
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(Item.bucketEmpty));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (heldItem.itemID == Item.bucketEmpty.itemID)
|
||||
{
|
||||
LiquidStack drain = tank.drain(LiquidContainerRegistry.BUCKET_VOLUME, false);
|
||||
if (drain != null && drain.amount >= LiquidContainerRegistry.BUCKET_VOLUME)
|
||||
{
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(Item.bucketWater));
|
||||
tank.drain(LiquidContainerRegistry.BUCKET_VOLUME, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
else if (heldItem.itemID == Item.glassBottle.itemID)
|
||||
{
|
||||
LiquidStack drain = tank.drain(LiquidContainerRegistry.BUCKET_VOLUME / 4, false);
|
||||
if (drain != null && drain.amount >= LiquidContainerRegistry.BUCKET_VOLUME / 4)
|
||||
{
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(Item.potion, 1, 0));
|
||||
tank.drain(LiquidContainerRegistry.BUCKET_VOLUME / 4, true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (heldItem.getItem() instanceof ItemArmor && ((ItemArmor) heldItem.getItem()).getArmorMaterial() == EnumArmorMaterial.CLOTH)
|
||||
{
|
||||
ItemArmor var13 = (ItemArmor) heldItem.getItem();
|
||||
var13.removeColor(heldItem);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLiving par5EntityLiving)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
int angle = MathHelper.floor_double((par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
|
||||
TileEntity ent = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
world.setBlockMetadata(x, y, z, angle + MetaGroup.getGroupStartMeta(MetaGroup.getGrouping(meta)));
|
||||
if (ent instanceof TileEntityAdvanced)
|
||||
{
|
||||
((TileEntityAdvanced) world.getBlockTileEntity(x, y, z)).initiate();
|
||||
}
|
||||
|
||||
world.notifyBlocksOfNeighborChange(x, y, z, this.blockID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
|
||||
return new ItemStack(this, 1, 0);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType()
|
||||
{
|
||||
return BlockRenderHelper.renderID;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -274,9 +274,8 @@ public class TileEntityPipe extends TileEntity implements ITankContainer, IReadO
|
|||
{
|
||||
connectedBlocks[i] = null;
|
||||
}
|
||||
|
||||
if (this.color != ColorCode.NONE && ent instanceof TileEntityTank && ((TileEntityTank) ent).getColor() != ColorCode.NONE && color != ((TileEntityTank) ent).getColor()
|
||||
)
|
||||
//TODO switch side catch for IPressure
|
||||
if (this.color != ColorCode.NONE && ent instanceof TileEntityTank && ((TileEntityTank) ent).getColor() != ColorCode.NONE && color != ((TileEntityTank) ent).getColor())
|
||||
{
|
||||
connectedBlocks[i] = null;
|
||||
}
|
||||
|
|
173
minecraft/liquidmechanics/common/tileentity/TileEntitySink.java
Normal file
173
minecraft/liquidmechanics/common/tileentity/TileEntitySink.java
Normal file
|
@ -0,0 +1,173 @@
|
|||
package liquidmechanics.common.tileentity;
|
||||
|
||||
import javax.swing.colorchooser.ColorSelectionModel;
|
||||
|
||||
import liquidmechanics.api.IColorCoded;
|
||||
import liquidmechanics.api.IReadOut;
|
||||
import liquidmechanics.api.IPressure;
|
||||
import liquidmechanics.api.helpers.LiquidData;
|
||||
import liquidmechanics.api.helpers.LiquidHandler;
|
||||
import liquidmechanics.api.helpers.ColorCode;
|
||||
import liquidmechanics.api.helpers.connectionHelper;
|
||||
import liquidmechanics.common.LiquidMechanics;
|
||||
import liquidmechanics.common.handlers.UpdateConverter;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.liquids.ILiquidTank;
|
||||
import net.minecraftforge.liquids.ITankContainer;
|
||||
import net.minecraftforge.liquids.LiquidContainerRegistry;
|
||||
import net.minecraftforge.liquids.LiquidStack;
|
||||
import net.minecraftforge.liquids.LiquidTank;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import universalelectricity.prefab.network.IPacketReceiver;
|
||||
import universalelectricity.prefab.network.PacketManager;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
public class TileEntitySink extends TileEntity implements IPacketReceiver, ITankContainer, IColorCoded
|
||||
{
|
||||
public TileEntity[] cc = { null, null, null, null, null, null };
|
||||
|
||||
private ColorCode color = ColorCode.BLUE;
|
||||
|
||||
public static final int LMax = 2;
|
||||
private int count = 100;
|
||||
private LiquidTank tank = new LiquidTank(LiquidContainerRegistry.BUCKET_VOLUME * LMax);
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
if (count++ >= 100)
|
||||
{
|
||||
triggerUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public void triggerUpdate()
|
||||
{
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
LiquidStack stack = new LiquidStack(0, 0, 0);
|
||||
if (this.tank.getLiquid() != null)
|
||||
{
|
||||
stack = this.tank.getLiquid();
|
||||
}
|
||||
Packet packet = PacketManager.getPacket(LiquidMechanics.CHANNEL, this, new Object[] { stack.itemID, stack.amount, stack.itemMeta });
|
||||
PacketManager.sendPacketToClients(packet, worldObj, new Vector3(this), 20);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public LiquidStack getStack()
|
||||
{
|
||||
return tank.getLiquid();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.readFromNBT(nbt);
|
||||
|
||||
LiquidStack liquid = new LiquidStack(0, 0, 0);
|
||||
liquid.readFromNBT(nbt.getCompoundTag("stored"));
|
||||
tank.setLiquid(liquid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.writeToNBT(nbt);
|
||||
if (tank.getLiquid() != null)
|
||||
{
|
||||
nbt.setTag("stored", tank.getLiquid().writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacketData(INetworkManager network, int packetType, Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput data)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.tank.setLiquid(new LiquidStack(data.readInt(), data.readInt(), data.readInt()));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
System.out.print("Fail reading data for Storage tank \n");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(ForgeDirection from, LiquidStack resource, boolean doFill)
|
||||
{
|
||||
if (resource == null || (!LiquidHandler.isEqual(resource, color.getLiquidData().getStack()))) { return 0; }
|
||||
return this.fill(0, resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(int tankIndex, LiquidStack resource, boolean doFill)
|
||||
{
|
||||
if (resource == null || tankIndex != 0) { return 0; }
|
||||
if (doFill)
|
||||
{
|
||||
triggerUpdate();
|
||||
}
|
||||
return this.tank.fill(resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LiquidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
return this.drain(0, maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LiquidStack drain(int tankIndex, int maxDrain, boolean doDrain)
|
||||
{
|
||||
if (tankIndex != 0 || this.tank.getLiquid() == null) { return null; }
|
||||
LiquidStack stack = this.tank.getLiquid();
|
||||
if (maxDrain < this.tank.getLiquid().amount)
|
||||
{
|
||||
stack = LiquidHandler.getStack(stack, maxDrain);
|
||||
}
|
||||
if (doDrain)
|
||||
{
|
||||
triggerUpdate();
|
||||
this.tank.drain(maxDrain, doDrain);
|
||||
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILiquidTank[] getTanks(ForgeDirection direction)
|
||||
{
|
||||
return new ILiquidTank[] { tank };
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILiquidTank getTank(ForgeDirection direction, LiquidStack type)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColor(Object obj)
|
||||
{
|
||||
// this.color = ColorCode.get(cc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ColorCode getColor()
|
||||
{
|
||||
return color;
|
||||
}
|
||||
}
|
BIN
minecraft/liquidmechanics/resource/Sink.png
Normal file
BIN
minecraft/liquidmechanics/resource/Sink.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
BIN
minecraft/liquidmechanics/resource/blue.png
Normal file
BIN
minecraft/liquidmechanics/resource/blue.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.7 KiB |
|
@ -7,6 +7,7 @@ tile.lmMachines.0.name=Pump
|
|||
tile.MechanicRod.name=Geared Rod
|
||||
tile.eValve.0.name=Release Valve
|
||||
tile.lmTank.name = Tank
|
||||
tile.lmSink.name = Sink
|
||||
|
||||
tile.lmPipe.0.name =Oil Pipe
|
||||
tile.lmPipe.1.name =Lava Pipe
|
||||
|
@ -52,5 +53,5 @@ item.lmPart.5.name=Slime Seal
|
|||
item.lmPart.6.name=Unfinished Tank
|
||||
item.lmPart.7.name=Valve
|
||||
|
||||
item.lmTool.0.name=Pipe Guage
|
||||
item.lmTool.0.name=Pipe Gauge
|
||||
|
||||
|
|
BIN
resources/models/Sink.tcn
Normal file
BIN
resources/models/Sink.tcn
Normal file
Binary file not shown.
Loading…
Add table
Reference in a new issue