Fixed channels not updating on world load
This commit is contained in:
parent
8936ff3fb9
commit
b421273726
3 changed files with 192 additions and 192 deletions
|
@ -18,87 +18,85 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
@SideOnly(Side.CLIENT)
|
||||
public class RenderChannel extends TileEntitySpecialRenderer
|
||||
{
|
||||
public static final RenderChannel INSTANCE = new RenderChannel();
|
||||
public static final RenderChannel INSTANCE = new RenderChannel();
|
||||
|
||||
public static ModelChannel MODEL_TROUGH_PIPE = new ModelChannel();
|
||||
public static ResourceLocation TEXTURE = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_PATH + "white.png");
|
||||
public static ModelChannel MODEL_TROUGH_PIPE = new ModelChannel();
|
||||
public static ResourceLocation TEXTURE = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_PATH + "white.png");
|
||||
|
||||
public static void render(int meta, byte sides)
|
||||
{
|
||||
RenderUtility.bind(Reference.BLOCK_TEXTURE_DIRECTORY + "planks_oak.png");
|
||||
MODEL_TROUGH_PIPE.render(sides, meta == 0 ? true : false);
|
||||
}
|
||||
public static void render(int meta, byte sides)
|
||||
{
|
||||
RenderUtility.bind(Reference.BLOCK_TEXTURE_DIRECTORY + "planks_oak.png");
|
||||
MODEL_TROUGH_PIPE.render(sides, meta == 0 ? true : false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float f)
|
||||
{
|
||||
//FluidStack liquid = ((TileChannel)tile).getInternalTank().getFluid();
|
||||
FluidStack liquid = new FluidStack(FluidRegistry.WATER, 1000);
|
||||
int cap = ((TileChannel)tile).getInternalTank().getCapacity();
|
||||
byte renderSides = (tile instanceof TileChannel ? ((TileChannel) tile).renderSides : (byte) 0);
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float f)
|
||||
{
|
||||
FluidStack liquid = ((TileChannel) tile).getInternalTank().getFluid();
|
||||
int capacity = ((TileChannel) tile).getInternalTank().getCapacity();
|
||||
byte renderSides = (tile instanceof TileChannel ? ((TileChannel) tile).renderSides : (byte) 0);
|
||||
|
||||
// FluidStack liquid = new FluidStack(FluidRegistry.WATER, cap);
|
||||
if (liquid != null && liquid.amount > 100)
|
||||
{
|
||||
float per = Math.max(1, (float) liquid.amount / (float) (cap));
|
||||
int[] displayList = RenderFluidHelper.getFluidDisplayLists(liquid, tile.worldObj, false);
|
||||
bindTexture(RenderFluidHelper.getFluidSheet(liquid));
|
||||
if (liquid != null && liquid.amount > 0)
|
||||
{
|
||||
float percentage = (float) liquid.amount / (float) capacity;
|
||||
int[] displayList = RenderFluidHelper.getFluidDisplayLists(liquid, tile.worldObj, false);
|
||||
bindTexture(RenderFluidHelper.getFluidSheet(liquid));
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glPushMatrix();
|
||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
GL11.glTranslatef((float) x + 0.3F, (float) y + 0.1F, (float) z + 0.3F);
|
||||
GL11.glScalef(0.4F, 0.4F, 0.4F);
|
||||
GL11.glTranslatef((float) x + 0.3F, (float) y + 0.1F, (float) z + 0.3F);
|
||||
GL11.glScalef(0.4F, 0.4F, 0.4F);
|
||||
|
||||
GL11.glCallList(displayList[(int) (per * (RenderFluidHelper.DISPLAY_STAGES - 1))]);
|
||||
GL11.glCallList(displayList[(int) (percentage * (RenderFluidHelper.DISPLAY_STAGES - 1))]);
|
||||
|
||||
GL11.glPopAttrib();
|
||||
GL11.glPopMatrix();
|
||||
GL11.glPopAttrib();
|
||||
GL11.glPopMatrix();
|
||||
|
||||
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
if (RenderUtility.canRenderSide(renderSides, direction) && direction != ForgeDirection.UP && direction != ForgeDirection.DOWN)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
if (RenderUtility.canRenderSide(renderSides, direction) && direction != ForgeDirection.UP && direction != ForgeDirection.DOWN)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
switch (direction.ordinal())
|
||||
{
|
||||
case 4:
|
||||
GL11.glTranslatef((float) x + 0F, (float) y + 0.1F, (float) z + 0.3F);
|
||||
break;
|
||||
case 5:
|
||||
GL11.glTranslatef((float) x + 0.7F, (float) y + 0.1F, (float) z + 0.3F);
|
||||
break;
|
||||
case 2:
|
||||
GL11.glTranslatef((float) x + 0.3F, (float) y + 0.1F, (float) z + 0F);
|
||||
break;
|
||||
case 3:
|
||||
GL11.glTranslatef((float) x + 0.3F, (float) y + 0.1F, (float) z + 0.7F);
|
||||
break;
|
||||
}
|
||||
GL11.glScalef(0.3F, 0.4F, 0.4F);
|
||||
switch (direction.ordinal())
|
||||
{
|
||||
case 4:
|
||||
GL11.glTranslatef((float) x + 0F, (float) y + 0.1F, (float) z + 0.3F);
|
||||
break;
|
||||
case 5:
|
||||
GL11.glTranslatef((float) x + 0.7F, (float) y + 0.1F, (float) z + 0.3F);
|
||||
break;
|
||||
case 2:
|
||||
GL11.glTranslatef((float) x + 0.3F, (float) y + 0.1F, (float) z + 0F);
|
||||
break;
|
||||
case 3:
|
||||
GL11.glTranslatef((float) x + 0.3F, (float) y + 0.1F, (float) z + 0.7F);
|
||||
break;
|
||||
}
|
||||
GL11.glScalef(0.3F, 0.4F, 0.4F);
|
||||
|
||||
GL11.glCallList(displayList[(int) (per * (RenderFluidHelper.DISPLAY_STAGES - 1))]);
|
||||
GL11.glCallList(displayList[(int) (percentage * (RenderFluidHelper.DISPLAY_STAGES - 1))]);
|
||||
|
||||
GL11.glPopAttrib();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
}
|
||||
GL11.glPopAttrib();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
|
||||
GL11.glScalef(1.0F, -1F, -1F);
|
||||
render(0, renderSides);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
|
||||
GL11.glScalef(1.0F, -1F, -1F);
|
||||
render(0, renderSides);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
|
@ -19,141 +19,143 @@ import calclavia.lib.utility.WrenchUtility;
|
|||
/** @author Darkguardsman */
|
||||
public class TileChannel extends TileFluidNetwork implements IBlockActivate, IFluidPipe
|
||||
{
|
||||
private boolean isExtracting = false;
|
||||
|
||||
public TileChannel()
|
||||
{
|
||||
this.getInternalTank().setCapacity(1 * FluidContainerRegistry.BUCKET_VOLUME);
|
||||
}
|
||||
private boolean isExtracting = false;
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
if (isExtracting && getNetwork().getTank().getFluidAmount() < getNetwork().getTank().getCapacity())
|
||||
{
|
||||
for (int i = 0; i < this.getConnections().length; i++)
|
||||
{
|
||||
Object obj = this.getConnections()[i];
|
||||
public TileChannel()
|
||||
{
|
||||
this.getInternalTank().setCapacity(1 * FluidContainerRegistry.BUCKET_VOLUME);
|
||||
}
|
||||
|
||||
if (obj instanceof IFluidHandler)
|
||||
{
|
||||
FluidStack drain = ((IFluidHandler) obj).drain(ForgeDirection.getOrientation(i).getOpposite(), getMaxFlowRate(), true);
|
||||
fill(null, drain, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
super.updateEntity();
|
||||
|
||||
@Override
|
||||
public boolean onActivated(EntityPlayer player)
|
||||
{
|
||||
if (WrenchUtility.isUsableWrench(player, player.getCurrentEquippedItem(), xCoord, yCoord, zCoord))
|
||||
{
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
isExtracting = !isExtracting;
|
||||
player.addChatMessage("Pipe extraction mode: " + isExtracting);
|
||||
WrenchUtility.damageWrench(player, player.getCurrentEquippedItem(), xCoord, yCoord, zCoord);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
if (isExtracting && getNetwork().getTank().getFluidAmount() < getNetwork().getTank().getCapacity())
|
||||
{
|
||||
for (int i = 0; i < this.getConnections().length; i++)
|
||||
{
|
||||
Object obj = this.getConnections()[i];
|
||||
|
||||
return false;
|
||||
}
|
||||
if (obj instanceof IFluidHandler)
|
||||
{
|
||||
FluidStack drain = ((IFluidHandler) obj).drain(ForgeDirection.getOrientation(i).getOpposite(), getMaxFlowRate(), true);
|
||||
fill(null, drain, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateConnectionSide(TileEntity tileEntity, ForgeDirection side)
|
||||
{
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
if (tileEntity instanceof IFluidPipe)
|
||||
{
|
||||
if (tileEntity instanceof TileChannel)
|
||||
{
|
||||
getNetwork().merge(((TileChannel) tileEntity).getNetwork());
|
||||
this.setRenderSide(side, true);
|
||||
connectedBlocks[side.ordinal()] = tileEntity;
|
||||
}
|
||||
}
|
||||
else if (tileEntity instanceof IFluidHandler)
|
||||
{
|
||||
this.setRenderSide(side, true);
|
||||
connectedBlocks[side.ordinal()] = tileEntity;
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean onActivated(EntityPlayer player)
|
||||
{
|
||||
if (WrenchUtility.isUsableWrench(player, player.getCurrentEquippedItem(), xCoord, yCoord, zCoord))
|
||||
{
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
isExtracting = !isExtracting;
|
||||
player.addChatMessage("Pipe extraction mode: " + isExtracting);
|
||||
WrenchUtility.damageWrench(player, player.getCurrentEquippedItem(), xCoord, yCoord, zCoord);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFlow()
|
||||
{
|
||||
return !isExtracting;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFluidNetwork getNetwork()
|
||||
{
|
||||
if (this.network == null)
|
||||
{
|
||||
this.network = new PipeNetwork();
|
||||
this.network.addConnector(this);
|
||||
}
|
||||
return this.network;
|
||||
}
|
||||
@Override
|
||||
public void validateConnectionSide(TileEntity tileEntity, ForgeDirection side)
|
||||
{
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
if (tileEntity instanceof IFluidPipe)
|
||||
{
|
||||
if (tileEntity instanceof TileChannel)
|
||||
{
|
||||
getNetwork().merge(((TileChannel) tileEntity).getNetwork());
|
||||
this.setRenderSide(side, true);
|
||||
connectedBlocks[side.ordinal()] = tileEntity;
|
||||
}
|
||||
}
|
||||
else if (tileEntity instanceof IFluidHandler)
|
||||
{
|
||||
this.setRenderSide(side, true);
|
||||
connectedBlocks[side.ordinal()] = tileEntity;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNetwork(IFluidNetwork network)
|
||||
{
|
||||
if (network instanceof PipeNetwork)
|
||||
{
|
||||
this.network = network;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean canFlow()
|
||||
{
|
||||
return !isExtracting;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.writeToNBT(nbt);
|
||||
nbt.setBoolean("isExtracting", isExtracting);
|
||||
}
|
||||
@Override
|
||||
public IFluidNetwork getNetwork()
|
||||
{
|
||||
if (this.network == null)
|
||||
{
|
||||
this.network = new PipeNetwork();
|
||||
this.network.addConnector(this);
|
||||
}
|
||||
return this.network;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.readFromNBT(nbt);
|
||||
isExtracting = nbt.getBoolean("isExtracting");
|
||||
}
|
||||
@Override
|
||||
public void setNetwork(IFluidNetwork network)
|
||||
{
|
||||
if (network instanceof PipeNetwork)
|
||||
{
|
||||
this.network = network;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPressureIn(ForgeDirection side)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.writeToNBT(nbt);
|
||||
nbt.setBoolean("isExtracting", isExtracting);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWrongPressure(ForgeDirection side, int pressure)
|
||||
{
|
||||
// TODO place fluid blocks into the world
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.readFromNBT(nbt);
|
||||
isExtracting = nbt.getBoolean("isExtracting");
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public int getPressureIn(ForgeDirection side)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxPressure()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public void onWrongPressure(ForgeDirection side, int pressure)
|
||||
{
|
||||
// TODO place fluid blocks into the world
|
||||
|
||||
@Override
|
||||
public int getPressure()
|
||||
{
|
||||
return this.getNetwork().getPressure();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxFlowRate()
|
||||
{
|
||||
return 500;
|
||||
}
|
||||
@Override
|
||||
public int getMaxPressure()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPressure()
|
||||
{
|
||||
return this.getNetwork().getPressure();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxFlowRate()
|
||||
{
|
||||
return 500;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ import cpw.mods.fml.common.registry.GameRegistry;
|
|||
*
|
||||
* @author Calclavia
|
||||
*/
|
||||
@Mod(modid = ResonantInduction.ID, name = ResonantInduction.NAME, version = Reference.VERSION, dependencies = "required-after:CalclaviaCore;before:IC2")
|
||||
@Mod(modid = ResonantInduction.ID, name = ResonantInduction.NAME, version = Reference.VERSION, dependencies = "required-after:ForgeMultipart@[1.0.0.244,);required-after:CalclaviaCore;before:IC2")
|
||||
@NetworkMod(channels = Reference.CHANNEL, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketHandler.class)
|
||||
@ModstatInfo(prefix = "resonantin")
|
||||
public class ResonantInduction
|
||||
|
|
Loading…
Reference in a new issue