Resolved #385 - Tanks now emit light

This commit is contained in:
Calclavia 2014-03-05 20:45:14 +08:00
parent bcf98a6b6a
commit f4fc1a7910
8 changed files with 95 additions and 370 deletions

View file

@ -23,7 +23,6 @@ import resonantinduction.archaic.fluid.grate.BlockGrate;
import resonantinduction.archaic.fluid.grate.TileGrate;
import resonantinduction.archaic.fluid.gutter.BlockGutter;
import resonantinduction.archaic.fluid.gutter.TileGutter;
import resonantinduction.archaic.fluid.tank.BlockTank;
import resonantinduction.archaic.fluid.tank.TileTank;
import resonantinduction.archaic.process.BlockCastingMold;
import resonantinduction.archaic.process.BlockMillstone;
@ -35,7 +34,6 @@ import resonantinduction.core.Settings;
import resonantinduction.core.TabRI;
import resonantinduction.core.prefab.imprint.ItemImprint;
import resonantinduction.core.resource.ItemHandCrank;
import resonantinduction.mechanical.fluid.pipe.ItemBlockFluidContainer;
import calclavia.lib.content.ContentRegistry;
import calclavia.lib.network.PacketAnnotation;
import calclavia.lib.network.PacketHandler;
@ -114,7 +112,7 @@ public class Archaic
blockGutter = contentRegistry.createTile(BlockGutter.class, TileGutter.class);
blockGrate = contentRegistry.createTile(BlockGrate.class, TileGrate.class);
blockFilter = contentRegistry.createTile(BlockFilter.class, TileFilter.class);
blockTank = contentRegistry.createBlock(BlockTank.class, ItemBlockFluidContainer.class, TileTank.class);
blockTank = contentRegistry.newBlock(TileTank.class);
itemHandCrank = contentRegistry.createItem(ItemHandCrank.class);
itemImprint = contentRegistry.createItem(ItemImprint.class);

View file

@ -1,5 +1,6 @@
package resonantinduction.archaic.fluid.gutter;
import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
@ -19,6 +20,11 @@ import calclavia.lib.utility.WorldUtility;
*/
public class TileGutter extends TilePressurizedNode implements IPressurizedNode
{
public TileGutter()
{
super(Material.wood);
}
@Override
public void refresh()
{

View file

@ -1,138 +0,0 @@
package resonantinduction.archaic.fluid.tank;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import resonantinduction.core.fluid.BlockFluidNode;
import resonantinduction.mechanical.fluid.pipe.ItemBlockFluidContainer;
import universalelectricity.api.UniversalElectricity;
import universalelectricity.api.vector.Vector3;
import calclavia.lib.render.block.BlockRenderingHandler;
import calclavia.lib.utility.FluidUtility;
import calclavia.lib.utility.inventory.InventoryUtility;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockTank extends BlockFluidNode
{
public BlockTank(int id)
{
super(id, UniversalElectricity.machine);
setHardness(1f);
setResistance(5f);
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
@SideOnly(Side.CLIENT)
public boolean renderAsNormalBlock()
{
return false;
}
@Override
@SideOnly(Side.CLIENT)
public int getRenderType()
{
return BlockRenderingHandler.ID;
}
@Override
public boolean shouldSideBeRendered(IBlockAccess blockAccess, int x, int y, int z, int side)
{
int checkBlockID = blockAccess.getBlockId(x, y, z);
return super.shouldSideBeRendered(blockAccess, x, y, z, side);
}
@Override
public boolean onMachineActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int side, float hitX, float hitY, float hitZ)
{
if (!world.isRemote)
return FluidUtility.playerActivatedFluidItem(world, x, y, z, entityplayer, side);
return true;
}
@Override
public TileEntity createNewTileEntity(World var1)
{
return new TileTank();
}
@Override
public boolean hasComparatorInputOverride()
{
return true;
}
@Override
public int getComparatorInputOverride(World world, int x, int y, int z, int par5)
{
TileTank tileEntity = (TileTank) world.getBlockTileEntity(x, y, z);
if (tileEntity != null && tileEntity.getNetwork().getTank().getFluid() != null)
{
return 15 * (tileEntity.getNetwork().getTank().getFluidAmount() / tileEntity.getNetwork().getTank().getCapacity());
}
return 0;
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z)
{
return new ItemStack(this, 1, 0);
}
@Override
public ArrayList<ItemStack> getBlockDropped(World world, int x, int y, int z, int metadata, int fortune)
{
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
TileEntity entity = world.getBlockTileEntity(x, y, z);
if (entity instanceof TileTank)
{
ret.add(new ItemStack(this, 1, 0));
}
return ret;
}
@SuppressWarnings("unchecked")
@Override
public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
{
par3List.add(new ItemStack(this, 1, 0));
}
@Override
public boolean onSneakMachineActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ)
{
if (!world.isRemote)
{
ItemStack dropStack = ItemBlockFluidContainer.getWrenchedItem(world, new Vector3(x, y, z));
if (dropStack != null)
{
if (entityPlayer.getHeldItem() == null)
{
entityPlayer.inventory.setInventorySlotContents(entityPlayer.inventory.currentItem, dropStack);
}
else
{
InventoryUtility.dropItemStack(world, new Vector3(x, y, z), dropStack);
}
world.setBlockToAir(x, y, z);
}
}
return true;
}
}

View file

@ -1,210 +0,0 @@
// Date: 6/3/2013 6:47:54 AM
// Template version 1.1
// Java generated by Techne
// Keep in mind that you still need to fill in some blanks
// - ZeuX
package resonantinduction.archaic.fluid.tank;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class ModelTank extends ModelBase
{
ModelRenderer botSiding;
ModelRenderer botRightOut;
ModelRenderer botLeftOut;
ModelRenderer topSiding;
ModelRenderer topRightOut;
ModelRenderer topLeftOut;
ModelRenderer leftSiding;
ModelRenderer leftBotSide;
ModelRenderer leftTopSide;
ModelRenderer leftSide;
ModelRenderer rightSiding;
ModelRenderer rightBotSide;
ModelRenderer rightTopSide;
ModelRenderer rightSide;
public ModelTank()
{
textureWidth = 128;
textureHeight = 128;
rightSiding = new ModelRenderer(this, 0, 19);
rightSiding.addBox(-7F, 11F, 7F, 2, 10, 1);
rightSiding.setRotationPoint(0F, 0F, 0F);
rightSiding.setTextureSize(128, 128);
rightSiding.mirror = true;
setRotation(rightSiding, 0F, 0F, 0F);
leftSiding = new ModelRenderer(this, 0, 19);
leftSiding.addBox(5F, 11F, 7F, 2, 10, 1);
leftSiding.setRotationPoint(0F, 0F, 0F);
leftSiding.setTextureSize(128, 128);
leftSiding.mirror = true;
setRotation(leftSiding, 0F, 0F, 0F);
topSiding = new ModelRenderer(this, 7, 8);
topSiding.addBox(-5F, 8F, 7F, 10, 3, 1);
topSiding.setRotationPoint(0F, 0F, 0F);
topSiding.setTextureSize(128, 128);
topSiding.mirror = true;
setRotation(topSiding, 0F, 0F, 0F);
botSiding = new ModelRenderer(this, 7, 8);
botSiding.addBox(-5F, 21F, 7F, 10, 3, 1);
botSiding.setRotationPoint(0F, 0F, 0F);
botSiding.setTextureSize(128, 128);
botSiding.mirror = true;
setRotation(botSiding, 0F, 0F, 0F);
botRightOut = new ModelRenderer(this, 0, 0);
botRightOut.addBox(-7F, 21F, 7F, 2, 3, 1);
botRightOut.setRotationPoint(0F, 0F, 0F);
botRightOut.setTextureSize(128, 128);
botRightOut.mirror = true;
setRotation(botRightOut, 0F, 0F, 0F);
botLeftOut = new ModelRenderer(this, 0, 0);
botLeftOut.addBox(5F, 21F, 7F, 2, 3, 1);
botLeftOut.setRotationPoint(0F, 0F, 0F);
botLeftOut.setTextureSize(128, 128);
botLeftOut.mirror = true;
setRotation(botLeftOut, 0F, 0F, 0F);
topRightOut = new ModelRenderer(this, 0, 0);
topRightOut.addBox(-7F, 8F, 7F, 2, 3, 1);
topRightOut.setRotationPoint(0F, 0F, 0F);
topRightOut.setTextureSize(128, 128);
topRightOut.mirror = true;
setRotation(topRightOut, 0F, 0F, 0F);
topLeftOut = new ModelRenderer(this, 0, 0);
topLeftOut.addBox(5F, 8F, 7F, 2, 3, 1);
topLeftOut.setRotationPoint(0F, 0F, 0F);
topLeftOut.setTextureSize(128, 128);
topLeftOut.mirror = true;
setRotation(topLeftOut, 0F, 0F, 0F);
leftSide = new ModelRenderer(this, 0, 19);
leftSide.addBox(7F, 11F, 7F, 1, 10, 1);
leftSide.setRotationPoint(0F, 0F, 0F);
leftSide.setTextureSize(128, 128);
leftSide.mirror = true;
setRotation(leftSide, 0F, 0F, 0F);
leftTopSide = new ModelRenderer(this, 0, 0);
leftTopSide.addBox(7F, 8F, 7F, 1, 3, 1);
leftTopSide.setRotationPoint(0F, 0F, 0F);
leftTopSide.setTextureSize(128, 128);
leftTopSide.mirror = true;
setRotation(leftTopSide, 0F, 0F, 0F);
leftBotSide = new ModelRenderer(this, 0, 0);
leftBotSide.addBox(7F, 21F, 7F, 1, 3, 1);
leftBotSide.setRotationPoint(0F, 0F, 0F);
leftBotSide.setTextureSize(128, 128);
leftBotSide.mirror = true;
setRotation(leftBotSide, 0F, 0F, 0F);
rightBotSide = new ModelRenderer(this, 0, 0);
rightBotSide.addBox(-8F, 21F, 7F, 1, 3, 1);
rightBotSide.setRotationPoint(0F, 0F, 0F);
rightBotSide.setTextureSize(128, 128);
rightBotSide.mirror = true;
setRotation(rightBotSide, 0F, 0F, 0F);
rightSide = new ModelRenderer(this, 0, 19);
rightSide.addBox(-8F, 11F, 7F, 1, 10, 1);
rightSide.setRotationPoint(0F, 0F, 0F);
rightSide.setTextureSize(128, 128);
rightSide.mirror = true;
setRotation(rightSide, 0F, 0F, 0F);
rightTopSide = new ModelRenderer(this, 0, 0);
rightTopSide.addBox(-8F, 8F, 7F, 1, 3, 1);
rightTopSide.setRotationPoint(0F, 0F, 0F);
rightTopSide.setTextureSize(128, 128);
rightTopSide.mirror = true;
setRotation(rightTopSide, 0F, 0F, 0F);
}
/**
* @param size - render size normal is 0.0625F
* @param left - is the an instance of this to the left
* @param right - "" to the right
* @param bot - "" to the bot
* @param top - "" to the top
*
* Not this only renders one side of the block. You will need to rotate it to face another
* direction then render it. If rotating up or down you will need to translate it a bit
*/
public void render(float size, boolean left, boolean right, boolean bot, boolean top)
{
if (!top)
{
topSiding.render(size);
topRightOut.render(size);
topLeftOut.render(size);
if (right)
{
rightTopSide.render(size);
}
if (left)
{
leftTopSide.render(size);
}
}
if (!bot)
{
botSiding.render(size);
botRightOut.render(size);
botLeftOut.render(size);
if (right)
{
rightBotSide.render(size);
}
if (left)
{
leftBotSide.render(size);
}
}
if (!right)
{
rightSiding.render(size);
rightBotSide.render(size);
rightTopSide.render(size);
rightSide.render(size);
if (top)
{
topRightOut.render(size);
}
if (bot)
{
botRightOut.render(size);
}
}
if (!left)
{
leftSiding.render(size);
leftBotSide.render(size);
leftTopSide.render(size);
leftSide.render(size);
if (top)
{
topLeftOut.render(size);
}
if (bot)
{
botLeftOut.render(size);
}
}
}
private void setRotation(ModelRenderer model, float x, float y, float z)
{
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
}

View file

@ -1,21 +1,82 @@
package resonantinduction.archaic.fluid.tank;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.FluidContainerRegistry;
import resonantinduction.api.mechanical.fluid.IPressure;
import resonantinduction.core.fluid.FluidDistributionetwork;
import resonantinduction.core.fluid.IFluidDistribution;
import resonantinduction.core.fluid.TileFluidDistribution;
import resonantinduction.mechanical.fluid.pipe.ItemBlockFluidContainer;
import universalelectricity.api.UniversalElectricity;
import universalelectricity.api.vector.Vector3;
import calclavia.lib.content.module.TileBlock.IComparatorInputOverride;
import calclavia.lib.utility.FluidUtility;
import calclavia.lib.utility.WorldUtility;
import calclavia.lib.utility.inventory.InventoryUtility;
public class TileTank extends TileFluidDistribution implements IPressure
public class TileTank extends TileFluidDistribution implements IPressure, IComparatorInputOverride
{
public static final int VOLUME = 16;
public TileTank()
{
super(UniversalElectricity.machine);
this.getInternalTank().setCapacity(VOLUME * FluidContainerRegistry.BUCKET_VOLUME);
isOpaqueCube = false;
normalRender = false;
itemBlock = ItemBlockFluidContainer.class;
}
protected boolean use(EntityPlayer player, int side, Vector3 vector3)
{
if (!world().isRemote)
{
if (player.isSneaking())
{
ItemStack dropStack = ItemBlockFluidContainer.getWrenchedItem(world(), position());
if (dropStack != null)
{
if (player.getHeldItem() == null)
{
player.inventory.setInventorySlotContents(player.inventory.currentItem, dropStack);
}
else
{
InventoryUtility.dropItemStack(world(), position(), dropStack);
}
position().setBlock(world(), 0);
}
}
return FluidUtility.playerActivatedFluidItem(world(), x(), y(), z(), player, side);
}
return true;
}
@Override
public int getComparatorInputOverride(int side)
{
if (getNetwork().getTank().getFluid() != null)
return (int) (15 * ((double) getNetwork().getTank().getFluidAmount() / (double) getNetwork().getTank().getCapacity()));
return 0;
}
@Override
public int getLightValue(IBlockAccess access)
{
if (getInternalTank().getFluid() != null)
return getInternalTank().getFluid().getFluid().getLuminosity();
return super.getLightValue(access);
}
@Override
@ -61,7 +122,7 @@ public class TileTank extends TileFluidDistribution implements IPressure
@Override
public int getPressure(ForgeDirection dir)
{
return 0;//(getInternalTank().getCapacity() - getInternalTank().getFluidAmount()) / 10;
return 0;// (getInternalTank().getCapacity() - getInternalTank().getFluidAmount()) / 10;
}
}

View file

@ -2,6 +2,7 @@ package resonantinduction.core.fluid;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.packet.Packet;
@ -34,6 +35,11 @@ import cpw.mods.fml.relauncher.SideOnly;
*/
public abstract class TileFluidDistribution extends TileFluidNode implements IFluidDistribution
{
public TileFluidDistribution(Material material)
{
super(material);
}
protected Object[] connectedBlocks = new Object[6];
/** Network used to link all parts together */
@ -47,6 +53,13 @@ public abstract class TileFluidDistribution extends TileFluidNode implements IFl
getNetwork().reconstruct();
}
@Override
protected void onNeighborChanged()
{
refresh();
getNetwork().reconstruct();
}
@Override
public void invalidate()
{

View file

@ -1,5 +1,6 @@
package resonantinduction.core.fluid;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.packet.Packet;
@ -8,9 +9,9 @@ import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTank;
import resonantinduction.core.ResonantInduction;
import universalelectricity.api.vector.Vector3;
import calclavia.lib.content.module.TileBase;
import calclavia.lib.network.IPacketReceiverWithID;
import calclavia.lib.network.PacketHandler;
import calclavia.lib.prefab.tile.TileAdvanced;
import calclavia.lib.utility.FluidUtility;
import com.google.common.io.ByteArrayDataInput;
@ -20,8 +21,13 @@ import com.google.common.io.ByteArrayDataInput;
*
* @author DarkGuardsman
*/
public abstract class TileFluidNode extends TileAdvanced implements IPacketReceiverWithID
public abstract class TileFluidNode extends TileBase implements IPacketReceiverWithID
{
public TileFluidNode(Material material)
{
super(material);
}
protected int pressure;
protected FluidTank tank;
@ -79,6 +85,7 @@ public abstract class TileFluidNode extends TileAdvanced implements IPacketRecei
{
tank = new FluidTank(data.readInt()).readFromNBT(PacketHandler.readNBTTagCompound(data));
pressure = data.readInt();
updateLight();
return true;
}
}

View file

@ -1,27 +1,14 @@
package resonantinduction.core.fluid;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.packet.Packet;
import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTank;
import net.minecraftforge.fluids.FluidTankInfo;
import resonantinduction.core.ResonantInduction;
import universalelectricity.api.vector.Vector3;
import calclavia.lib.network.IPacketReceiverWithID;
import calclavia.lib.network.PacketHandler;
import calclavia.lib.prefab.tile.TileAdvanced;
import calclavia.lib.utility.FluidUtility;
import calclavia.lib.utility.WorldUtility;
import com.google.common.io.ByteArrayDataInput;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/**
* A prefab class for tiles that use the fluid network.
@ -35,8 +22,9 @@ public abstract class TilePressurizedNode extends TileFluidNode implements IPres
/** Network used to link all parts together */
protected PressureNetwork network;
public TilePressurizedNode()
public TilePressurizedNode(Material material)
{
super(material);
getInternalTank().setCapacity(FluidContainerRegistry.BUCKET_VOLUME);
}