Started work on Portable Tank

This commit is contained in:
Aidan C. Brady 2014-06-18 03:01:23 +02:00
parent ead4af2f78
commit fd74ee5c92
22 changed files with 665 additions and 71 deletions

View file

@ -4,6 +4,12 @@ import net.minecraft.entity.Entity;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
/**
* Chunk3D - an integer-based way to keep track of and perform operations on chunks in a Minecraft-based environment. This also takes
* in account the dimension the chunk is in.
* @author aidancbrady
*
*/
public class Chunk3D
{
public int dimensionId;
@ -11,6 +17,12 @@ public class Chunk3D
public int xCoord;
public int zCoord;
/**
* Creates a Chunk3D object from the given x and z coordinates, as well as a dimension.
* @param x - chunk x location
* @param z - chunk z location
* @param dimension - the dimension this Chunk3D is in
*/
public Chunk3D(int x, int z, int dimension)
{
xCoord = x;
@ -19,6 +31,10 @@ public class Chunk3D
dimensionId = dimension;
}
/**
* Creates a Chunk3D from an entity based on it's location and dimension.
* @param entity - the entity to get the Chunk3D object from
*/
public Chunk3D(Entity entity)
{
xCoord = ((int)entity.posX) >> 4;
@ -27,6 +43,10 @@ public class Chunk3D
dimensionId = entity.dimension;
}
/**
* Creates a Chunk3D from a Coord4D based on it's coordinates and dimension.
* @param coord - the Coord4D object to get this Chunk3D from
*/
public Chunk3D(Coord4D coord)
{
xCoord = coord.xCoord >> 4;
@ -35,11 +55,21 @@ public class Chunk3D
dimensionId = coord.dimensionId;
}
/**
* Whether or not this chunk exists in the given world.
* @param world - the world to check in
* @return if the chunk exists
*/
public boolean exists(World world)
{
return world.getChunkProvider().chunkExists(xCoord, zCoord);
}
/**
* Gets a Chunk object corresponding to this Chunk3D's coordinates.
* @param world - the world to get the Chunk object from
* @return the corresponding Chunk object
*/
public Chunk getChunk(World world)
{
return world.getChunkFromChunkCoords(xCoord, zCoord);

View file

@ -0,0 +1,27 @@
package mekanism.api;
import net.minecraft.entity.player.EntityPlayer;
/**
* Implement this in your TileEntity class if your block can be modified by a Configurator.
* @author aidancbrady
*
*/
public interface IConfigurable
{
/**
* Called when a player shift-right clicks this block with a Configurator.
* @param player - the player who clicked the block
* @param side - the side the block was clicked on
* @return whether or not an action was performed
*/
public boolean onSneakRightClick(EntityPlayer player, int side);
/**
* Called when a player right clicks this block with a Configurator.
* @param player - the player who clicked the block
* @param side - the side the block was clicked on
* @return whether or not an action was performed
*/
public boolean onRightClick(EntityPlayer player, int side);
}

View file

@ -2,11 +2,30 @@ package mekanism.api;
import net.minecraft.nbt.NBTTagCompound;
/**
* Implement this in your TileEntity class if you wish for Mekanism filters to be able to store any of their
* information.
* @author aidancbrady
*
*/
public interface IFilterAccess
{
/**
* Collects the TileEntity's filter card data into the parameterized NBTTagCompound.
* @param nbtTags - the NBTTagCompound of the filter card ItemStack
* @return the NBTTagCompound that now contains the TileEntity's filter card data
*/
public NBTTagCompound getFilterData(NBTTagCompound nbtTags);
/**
* Retrieves the TileEntity's data contained in the filter card based on the given NBTTagCompopund.
* @param nbtTags - the NBTTagCompound of the filter card ItemStack
*/
public void setFilterData(NBTTagCompound nbtTags);
/**
* A String name of this TileEntity that will be displayed as the type of data on the filter card.
* @return the String name of this TileEntity
*/
public String getDataType();
}

View file

@ -71,6 +71,7 @@ import mekanism.client.render.tileentity.RenderGasTank;
import mekanism.client.render.tileentity.RenderLogisticalSorter;
import mekanism.client.render.tileentity.RenderMetallurgicInfuser;
import mekanism.client.render.tileentity.RenderObsidianTNT;
import mekanism.client.render.tileentity.RenderPortableTank;
import mekanism.client.render.tileentity.RenderPressurizedReactionChamber;
import mekanism.client.render.tileentity.RenderRotaryCondensentrator;
import mekanism.client.render.tileentity.RenderSalinationController;
@ -119,6 +120,7 @@ import mekanism.common.tile.TileEntityMetallurgicInfuser;
import mekanism.common.tile.TileEntityObsidianTNT;
import mekanism.common.tile.TileEntityOsmiumCompressor;
import mekanism.common.tile.TileEntityPRC;
import mekanism.common.tile.TileEntityPortableTank;
import mekanism.common.tile.TileEntityPrecisionSawmill;
import mekanism.common.tile.TileEntityPurificationChamber;
import mekanism.common.tile.TileEntityRotaryCondensentrator;
@ -294,6 +296,7 @@ public class ClientProxy extends CommonProxy
ClientRegistry.registerTileEntity(TileEntityChemicalCrystallizer.class, "ChemicalCrystallizer", new RenderChemicalCrystallizer());
ClientRegistry.registerTileEntity(TileEntitySeismicVibrator.class, "SeismicVibrator", new RenderSeismicVibrator());
ClientRegistry.registerTileEntity(TileEntityPRC.class, "PressurizedReactionChamber", new RenderPressurizedReactionChamber());
ClientRegistry.registerTileEntity(TileEntityPortableTank.class, "PortableTank", new RenderPortableTank());
}
@Override

View file

@ -0,0 +1,106 @@
package mekanism.client.model;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
public class ModelPortableTank extends ModelBase
{
ModelRenderer Base;
ModelRenderer PoleFL;
ModelRenderer PoleLB;
ModelRenderer PoleBR;
ModelRenderer PoleRF;
ModelRenderer Top;
ModelRenderer FrontGlass;
ModelRenderer BackGlass;
ModelRenderer RightGlass;
ModelRenderer LeftGlass;
public ModelPortableTank()
{
textureWidth = 128;
textureHeight = 128;
Base = new ModelRenderer(this, 0, 0);
Base.addBox(0F, 0F, 0F, 12, 1, 12);
Base.setRotationPoint(-6F, 23F, -6F);
Base.setTextureSize(128, 128);
Base.mirror = true;
setRotation(Base, 0F, 0F, 0F);
PoleFL = new ModelRenderer(this, 48, 0);
PoleFL.addBox(0F, 0F, 0F, 1, 14, 1);
PoleFL.setRotationPoint(5F, 9F, -6F);
PoleFL.setTextureSize(128, 128);
PoleFL.mirror = true;
setRotation(PoleFL, 0F, 0F, 0F);
PoleLB = new ModelRenderer(this, 48, 0);
PoleLB.addBox(0F, 0F, 0F, 1, 14, 1);
PoleLB.setRotationPoint(5F, 9F, 5F);
PoleLB.setTextureSize(128, 128);
PoleLB.mirror = true;
setRotation(PoleLB, 0F, 0F, 0F);
PoleBR = new ModelRenderer(this, 48, 0);
PoleBR.addBox(0F, 0F, 0F, 1, 14, 1);
PoleBR.setRotationPoint(-6F, 9F, 5F);
PoleBR.setTextureSize(128, 128);
PoleBR.mirror = true;
setRotation(PoleBR, 0F, 0F, 0F);
PoleRF = new ModelRenderer(this, 48, 0);
PoleRF.addBox(0F, 0F, 0F, 1, 14, 1);
PoleRF.setRotationPoint(-6F, 9F, -6F);
PoleRF.setTextureSize(128, 128);
PoleRF.mirror = true;
setRotation(PoleRF, 0F, 0F, 0F);
Top = new ModelRenderer(this, 0, 0);
Top.addBox(0F, 0F, 0F, 12, 1, 12);
Top.setRotationPoint(-6F, 8F, -6F);
Top.setTextureSize(128, 128);
Top.mirror = true;
setRotation(Top, 0F, 0F, 0F);
FrontGlass = new ModelRenderer(this, 0, 13);
FrontGlass.addBox(0F, 0F, 0F, 10, 14, 1);
FrontGlass.setRotationPoint(-5F, 9F, -6F);
FrontGlass.setTextureSize(128, 128);
FrontGlass.mirror = true;
setRotation(FrontGlass, 0F, 0F, 0F);
BackGlass = new ModelRenderer(this, 0, 28);
BackGlass.addBox(0F, 0F, 3F, 10, 14, 1);
BackGlass.setRotationPoint(-5F, 9F, 2F);
BackGlass.setTextureSize(128, 128);
BackGlass.mirror = true;
setRotation(BackGlass, 0F, 0F, 0F);
RightGlass = new ModelRenderer(this, 22, 13);
RightGlass.addBox(0F, 0F, 0F, 1, 14, 10);
RightGlass.setRotationPoint(-6F, 9F, -5F);
RightGlass.setTextureSize(128, 128);
RightGlass.mirror = true;
setRotation(RightGlass, 0F, 0F, 0F);
LeftGlass = new ModelRenderer(this, 22, 37);
LeftGlass.addBox(0F, 0F, 0F, 1, 14, 10);
LeftGlass.setRotationPoint(5F, 9F, -5F);
LeftGlass.setTextureSize(128, 128);
LeftGlass.mirror = true;
setRotation(LeftGlass, 0F, 0F, 0F);
}
public void render(float size)
{
Base.render(size);
PoleFL.render(size);
PoleLB.render(size);
PoleBR.render(size);
PoleRF.render(size);
Top.render(size);
FrontGlass.render(size);
BackGlass.render(size);
RightGlass.render(size);
LeftGlass.render(size);
}
private void setRotation(ModelRenderer model, float x, float y, float z)
{
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
}

View file

@ -13,6 +13,7 @@ import mekanism.client.model.ModelGasMask;
import mekanism.client.model.ModelGasTank;
import mekanism.client.model.ModelJetpack;
import mekanism.client.model.ModelObsidianTNT;
import mekanism.client.model.ModelPortableTank;
import mekanism.client.model.ModelRobit;
import mekanism.client.model.ModelScubaTank;
import mekanism.client.render.MekanismRenderer;
@ -79,6 +80,7 @@ public class ItemRenderingHandler implements IItemRenderer
public ModelScubaTank scubaTank = new ModelScubaTank();
public ModelFreeRunners freeRunners = new ModelFreeRunners();
public ModelAtomicDisassembler atomicDisassembler = new ModelAtomicDisassembler();
public ModelPortableTank portableTank = new ModelPortableTank();
private final RenderBalloon balloonRenderer = new RenderBalloon();
private final RenderBin binRenderer = (RenderBin)TileEntityRendererDispatcher.instance.mapSpecialRenderers.get(TileEntityBin.class);
@ -435,6 +437,14 @@ public class ItemRenderingHandler implements IItemRenderer
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glPopAttrib();
}
else if(MachineType.get(item) == MachineType.PORTABLE_TANK)
{
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
GL11.glRotatef(270F, 0.0F, -1.0F, 0.0F);
GL11.glTranslatef(0.0F, -1.06F, 0.05F);
Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "PortableTank.png"));
portableTank.render(0.0625F);
}
else {
if(item.getItem() instanceof ItemBlockMachine)
{

View file

@ -0,0 +1,45 @@
package mekanism.client.render.tileentity;
import mekanism.client.model.ModelPortableTank;
import mekanism.common.tile.TileEntityPortableTank;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class RenderPortableTank extends TileEntitySpecialRenderer
{
private ModelPortableTank model = new ModelPortableTank();
@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick)
{
renderAModelAt((TileEntityPortableTank)tileEntity, x, y, z, partialTick);
}
private void renderAModelAt(TileEntityPortableTank tileEntity, double x, double y, double z, float partialTick)
{
GL11.glPushMatrix();
GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F);
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "PortableTank" + (tileEntity.isActive ? "On" : "") + ".png"));
switch(tileEntity.facing)
{
case 2: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break;
case 3: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break;
case 4: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break;
case 5: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break;
}
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
model.render(0.0625F);
GL11.glPopMatrix();
}
}

View file

@ -66,6 +66,7 @@ import mekanism.common.tile.TileEntityMetallurgicInfuser;
import mekanism.common.tile.TileEntityObsidianTNT;
import mekanism.common.tile.TileEntityOsmiumCompressor;
import mekanism.common.tile.TileEntityPRC;
import mekanism.common.tile.TileEntityPortableTank;
import mekanism.common.tile.TileEntityPrecisionSawmill;
import mekanism.common.tile.TileEntityPurificationChamber;
import mekanism.common.tile.TileEntityRotaryCondensentrator;
@ -129,6 +130,7 @@ public class CommonProxy
GameRegistry.registerTileEntity(TileEntityChemicalCrystallizer.class, "ChemicalCrystallizer");
GameRegistry.registerTileEntity(TileEntitySeismicVibrator.class, "SeismicVibrator");
GameRegistry.registerTileEntity(TileEntityPRC.class, "PressurizedReactionChamber");
GameRegistry.registerTileEntity(TileEntityPortableTank.class, "PortableTank");
}
/**

View file

@ -1,10 +0,0 @@
package mekanism.common;
import net.minecraft.entity.player.EntityPlayer;
public interface IConfigurable
{
public boolean onSneakRightClick(EntityPlayer player, int side);
public boolean onRightClick(EntityPlayer player, int side);
}

View file

@ -49,6 +49,7 @@ import mekanism.common.tile.TileEntityLogisticalSorter;
import mekanism.common.tile.TileEntityMetallurgicInfuser;
import mekanism.common.tile.TileEntityOsmiumCompressor;
import mekanism.common.tile.TileEntityPRC;
import mekanism.common.tile.TileEntityPortableTank;
import mekanism.common.tile.TileEntityPrecisionSawmill;
import mekanism.common.tile.TileEntityPurificationChamber;
import mekanism.common.tile.TileEntityRotaryCondensentrator;
@ -114,6 +115,7 @@ import dan200.computercraft.api.peripheral.IPeripheralProvider;
* 1:8: Chemical Crystallizer
* 1:9: Seismic Vibrator
* 1:10: Pressurized Reaction Chamber
* 1:11: Portable Tank
* @author AidanBrady
*
*/
@ -742,6 +744,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer
}
}
}
return false;
}
@ -1105,33 +1108,34 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer
public static enum MachineType
{
ENRICHMENT_CHAMBER(Mekanism.MachineBlock, 0, "EnrichmentChamber", 3, Mekanism.enrichmentChamberUsage*400, TileEntityEnrichmentChamber.class, false, true),
OSMIUM_COMPRESSOR(Mekanism.MachineBlock, 1, "OsmiumCompressor", 4, Mekanism.osmiumCompressorUsage*400, TileEntityOsmiumCompressor.class, false, true),
COMBINER(Mekanism.MachineBlock, 2, "Combiner", 5, Mekanism.combinerUsage*400, TileEntityCombiner.class, false, true),
CRUSHER(Mekanism.MachineBlock, 3, "Crusher", 6, Mekanism.crusherUsage*400, TileEntityCrusher.class, false, true),
DIGITAL_MINER(Mekanism.MachineBlock, 4, "DigitalMiner", 2, 100000, TileEntityDigitalMiner.class, true, true),
BASIC_FACTORY(Mekanism.MachineBlock, 5, "BasicFactory", 11, Mekanism.factoryUsage*3*400, TileEntityFactory.class, false, true),
ADVANCED_FACTORY(Mekanism.MachineBlock, 6, "AdvancedFactory", 11, Mekanism.factoryUsage*5*400, TileEntityAdvancedFactory.class, false, true),
ELITE_FACTORY(Mekanism.MachineBlock, 7, "EliteFactory", 11, Mekanism.factoryUsage*7*400, TileEntityEliteFactory.class, false, true),
METALLURGIC_INFUSER(Mekanism.MachineBlock, 8, "MetallurgicInfuser", 12, Mekanism.metallurgicInfuserUsage*400, TileEntityMetallurgicInfuser.class, true, true),
PURIFICATION_CHAMBER(Mekanism.MachineBlock, 9, "PurificationChamber", 15, Mekanism.purificationChamberUsage*400, TileEntityPurificationChamber.class, false, true),
ENERGIZED_SMELTER(Mekanism.MachineBlock, 10, "EnergizedSmelter", 16, Mekanism.energizedSmelterUsage*400, TileEntityEnergizedSmelter.class, false, true),
TELEPORTER(Mekanism.MachineBlock, 11, "Teleporter", 13, 5000000, TileEntityTeleporter.class, false, false),
ELECTRIC_PUMP(Mekanism.MachineBlock, 12, "ElectricPump", 17, 10000, TileEntityElectricPump.class, true, false),
ELECTRIC_CHEST(Mekanism.MachineBlock, 13, "ElectricChest", -1, 12000, TileEntityElectricChest.class, true, false),
CHARGEPAD(Mekanism.MachineBlock, 14, "Chargepad", -1, 10000, TileEntityChargepad.class, true, false),
LOGISTICAL_SORTER(Mekanism.MachineBlock, 15, "LogisticalSorter", -1, 0, TileEntityLogisticalSorter.class, true, false),
ROTARY_CONDENSENTRATOR(Mekanism.MachineBlock2, 0, "RotaryCondensentrator", 7, 20000, TileEntityRotaryCondensentrator.class, true, false),
CHEMICAL_OXIDIZER(Mekanism.MachineBlock2, 1, "ChemicalOxidizer", 29, 20000, TileEntityChemicalOxidizer.class, true, false),
CHEMICAL_INFUSER(Mekanism.MachineBlock2, 2, "ChemicalInfuser", 30, 20000, TileEntityChemicalInfuser.class, true, false),
CHEMICAL_INJECTION_CHAMBER(Mekanism.MachineBlock2, 3, "ChemicalInjectionChamber", 31, Mekanism.chemicalInjectionChamberUsage*400, TileEntityChemicalInjectionChamber.class, false, true),
ELECTROLYTIC_SEPARATOR(Mekanism.MachineBlock2, 4, "ElectrolyticSeparator", 32, 400000, TileEntityElectrolyticSeparator.class, true, false),
PRECISION_SAWMILL(Mekanism.MachineBlock2, 5, "PrecisionSawmill", 34, Mekanism.precisionSawmillUsage*400, TileEntityPrecisionSawmill.class, false, true),
CHEMICAL_DISSOLUTION_CHAMBER(Mekanism.MachineBlock2, 6, "ChemicalDissolutionChamber", 35, 20000, TileEntityChemicalDissolutionChamber.class, true, false),
CHEMICAL_WASHER(Mekanism.MachineBlock2, 7, "ChemicalWasher", 36, 20000, TileEntityChemicalWasher.class, true, false),
CHEMICAL_CRYSTALLIZER(Mekanism.MachineBlock2, 8, "ChemicalCrystallizer", 37, 20000, TileEntityChemicalCrystallizer.class, true, false),
SEISMIC_VIBRATOR(Mekanism.MachineBlock2, 9, "SeismicVibrator", 39, 20000, TileEntitySeismicVibrator.class, true, false),
PRESSURIZED_REACTION_CHAMBER(Mekanism.MachineBlock2, 10, "PressurizedReactionChamber", 40, 20000, TileEntityPRC.class, true, false);
ENRICHMENT_CHAMBER(Mekanism.MachineBlock, 0, "EnrichmentChamber", 3, Mekanism.enrichmentChamberUsage*400, TileEntityEnrichmentChamber.class, true, false, true),
OSMIUM_COMPRESSOR(Mekanism.MachineBlock, 1, "OsmiumCompressor", 4, Mekanism.osmiumCompressorUsage*400, TileEntityOsmiumCompressor.class, true, false, true),
COMBINER(Mekanism.MachineBlock, 2, "Combiner", 5, Mekanism.combinerUsage*400, TileEntityCombiner.class, true, false, true),
CRUSHER(Mekanism.MachineBlock, 3, "Crusher", 6, Mekanism.crusherUsage*400, TileEntityCrusher.class, true, false, true),
DIGITAL_MINER(Mekanism.MachineBlock, 4, "DigitalMiner", 2, 100000, TileEntityDigitalMiner.class, true, true, true),
BASIC_FACTORY(Mekanism.MachineBlock, 5, "BasicFactory", 11, Mekanism.factoryUsage*3*400, TileEntityFactory.class, true, false, true),
ADVANCED_FACTORY(Mekanism.MachineBlock, 6, "AdvancedFactory", 11, Mekanism.factoryUsage*5*400, TileEntityAdvancedFactory.class, true, false, true),
ELITE_FACTORY(Mekanism.MachineBlock, 7, "EliteFactory", 11, Mekanism.factoryUsage*7*400, TileEntityEliteFactory.class, true, false, true),
METALLURGIC_INFUSER(Mekanism.MachineBlock, 8, "MetallurgicInfuser", 12, Mekanism.metallurgicInfuserUsage*400, TileEntityMetallurgicInfuser.class, true, true, true),
PURIFICATION_CHAMBER(Mekanism.MachineBlock, 9, "PurificationChamber", 15, Mekanism.purificationChamberUsage*400, TileEntityPurificationChamber.class, true, false, true),
ENERGIZED_SMELTER(Mekanism.MachineBlock, 10, "EnergizedSmelter", 16, Mekanism.energizedSmelterUsage*400, TileEntityEnergizedSmelter.class, true, false, true),
TELEPORTER(Mekanism.MachineBlock, 11, "Teleporter", 13, 5000000, TileEntityTeleporter.class, true, false, false),
ELECTRIC_PUMP(Mekanism.MachineBlock, 12, "ElectricPump", 17, 10000, TileEntityElectricPump.class, true, true, false),
ELECTRIC_CHEST(Mekanism.MachineBlock, 13, "ElectricChest", -1, 12000, TileEntityElectricChest.class, true, true, false),
CHARGEPAD(Mekanism.MachineBlock, 14, "Chargepad", -1, 10000, TileEntityChargepad.class, true, true, false),
LOGISTICAL_SORTER(Mekanism.MachineBlock, 15, "LogisticalSorter", -1, 0, TileEntityLogisticalSorter.class, false, true, false),
ROTARY_CONDENSENTRATOR(Mekanism.MachineBlock2, 0, "RotaryCondensentrator", 7, 20000, TileEntityRotaryCondensentrator.class, true, true, false),
CHEMICAL_OXIDIZER(Mekanism.MachineBlock2, 1, "ChemicalOxidizer", 29, 20000, TileEntityChemicalOxidizer.class, true, true, false),
CHEMICAL_INFUSER(Mekanism.MachineBlock2, 2, "ChemicalInfuser", 30, 20000, TileEntityChemicalInfuser.class, true, true, false),
CHEMICAL_INJECTION_CHAMBER(Mekanism.MachineBlock2, 3, "ChemicalInjectionChamber", 31, Mekanism.chemicalInjectionChamberUsage*400, TileEntityChemicalInjectionChamber.class, true, false, true),
ELECTROLYTIC_SEPARATOR(Mekanism.MachineBlock2, 4, "ElectrolyticSeparator", 32, 400000, TileEntityElectrolyticSeparator.class, true, true, false),
PRECISION_SAWMILL(Mekanism.MachineBlock2, 5, "PrecisionSawmill", 34, Mekanism.precisionSawmillUsage*400, TileEntityPrecisionSawmill.class, true, false, true),
CHEMICAL_DISSOLUTION_CHAMBER(Mekanism.MachineBlock2, 6, "ChemicalDissolutionChamber", 35, 20000, TileEntityChemicalDissolutionChamber.class, true, true, false),
CHEMICAL_WASHER(Mekanism.MachineBlock2, 7, "ChemicalWasher", 36, 20000, TileEntityChemicalWasher.class, true, true, false),
CHEMICAL_CRYSTALLIZER(Mekanism.MachineBlock2, 8, "ChemicalCrystallizer", 37, 20000, TileEntityChemicalCrystallizer.class, true, true, false),
SEISMIC_VIBRATOR(Mekanism.MachineBlock2, 9, "SeismicVibrator", 39, 20000, TileEntitySeismicVibrator.class, true, true, false),
PRESSURIZED_REACTION_CHAMBER(Mekanism.MachineBlock2, 10, "PressurizedReactionChamber", 40, 20000, TileEntityPRC.class, true, true, false),
PORTABLE_TANK(Mekanism.MachineBlock2, 11, "PortableTank", 41, 0, TileEntityPortableTank.class, false, true, false);
public Block typeBlock;
public int meta;
@ -1139,10 +1143,11 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer
public int guiId;
public double baseEnergy;
public Class<? extends TileEntity> tileEntityClass;
public boolean isElectric;
public boolean hasModel;
public boolean supportsUpgrades;
private MachineType(Block block, int i, String s, int j, double k, Class<? extends TileEntity> tileClass, boolean model, boolean upgrades)
private MachineType(Block block, int i, String s, int j, double k, Class<? extends TileEntity> tileClass, boolean electric, boolean model, boolean upgrades)
{
typeBlock = block;
meta = i;
@ -1150,6 +1155,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer
guiId = j;
baseEnergy = k;
tileEntityClass = tileClass;
isElectric = electric;
hasModel = model;
supportsUpgrades = upgrades;
}

View file

@ -145,7 +145,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
list.add(EnumColor.INDIGO + MekanismUtils.localize("tooltip.locked") + ": " + EnumColor.GREY + LangUtils.transYesNo(getLocked(itemstack)));
}
if(type != MachineType.LOGISTICAL_SORTER)
if(type.isElectric)
{
list.add(EnumColor.BRIGHT_GREEN + MekanismUtils.localize("tooltip.storedEnergy") + ": " + EnumColor.GREY + MekanismUtils.getEnergyDisplay(getEnergyStored(itemstack)));
}
@ -777,7 +777,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
@Override
public double getEnergy(ItemStack itemStack)
{
if(itemStack.stackTagCompound == null)
if(itemStack.stackTagCompound == null || !MachineType.get(itemStack).isElectric)
{
return 0;
}
@ -788,6 +788,11 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
@Override
public void setEnergy(ItemStack itemStack, double amount)
{
if(!MachineType.get(itemStack).isElectric)
{
return;
}
if(itemStack.stackTagCompound == null)
{
itemStack.setTagCompound(new NBTTagCompound());
@ -812,7 +817,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
@Override
public boolean canReceive(ItemStack itemStack)
{
return true;
return MachineType.get(itemStack).isElectric;
}
@Override

View file

@ -6,7 +6,7 @@ import java.util.Random;
import mekanism.api.Coord4D;
import mekanism.api.EnumColor;
import mekanism.common.IConfigurable;
import mekanism.api.IConfigurable;
import mekanism.common.IInvConfiguration;
import mekanism.common.Mekanism;
import mekanism.common.network.PacketTileEntity.TileEntityMessage;

View file

@ -11,11 +11,11 @@ import java.util.Set;
import mekanism.api.Coord4D;
import mekanism.api.EnumColor;
import mekanism.api.IConfigurable;
import mekanism.api.transmitters.IBlockableConnection;
import mekanism.api.transmitters.ITransmitter;
import mekanism.api.transmitters.TransmissionType;
import mekanism.client.render.RenderPartTransmitter;
import mekanism.common.IConfigurable;
import mekanism.common.ITileNetwork;
import mekanism.common.Mekanism;
import mekanism.common.Tier;

View file

@ -4,12 +4,12 @@ import java.util.HashSet;
import java.util.Set;
import mekanism.api.Coord4D;
import mekanism.api.IConfigurable;
import mekanism.api.transmitters.DynamicNetwork;
import mekanism.api.transmitters.IGridTransmitter;
import mekanism.api.transmitters.TransmissionType;
import mekanism.api.transmitters.TransmitterNetworkRegistry;
import mekanism.client.ClientTickHandler;
import mekanism.common.IConfigurable;
import mekanism.common.Mekanism;
import mekanism.common.network.PacketTransmitterUpdate.PacketType;
import mekanism.common.network.PacketTransmitterUpdate.TransmitterUpdateMessage;

View file

@ -5,8 +5,8 @@ import io.netty.buffer.ByteBuf;
import java.util.ArrayList;
import mekanism.api.Coord4D;
import mekanism.api.IConfigurable;
import mekanism.common.IActiveState;
import mekanism.common.IConfigurable;
import mekanism.common.ILogisticalTransporter;
import mekanism.common.Mekanism;
import mekanism.common.item.ItemBlockBasic;

View file

@ -12,7 +12,7 @@ import java.util.Set;
import mekanism.api.Coord4D;
import mekanism.api.EnumColor;
import mekanism.common.IConfigurable;
import mekanism.api.IConfigurable;
import mekanism.common.ISustainedTank;
import mekanism.common.Mekanism;
import mekanism.common.network.PacketTileEntity.TileEntityMessage;

View file

@ -353,22 +353,12 @@ public class TileEntityPRC extends TileEntityBasicMachine implements IFluidHandl
@Override
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain)
{
if(from == ForgeDirection.getOrientation(facing).getOpposite() && inputFluidTank.getFluid() != null && inputFluidTank.getFluid().isFluidEqual(resource))
{
return inputFluidTank.drain(resource.amount, doDrain);
}
return null;
}
@Override
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
{
if(from == ForgeDirection.getOrientation(facing).getOpposite())
{
return inputFluidTank.drain(maxDrain, doDrain);
}
return null;
}
@ -386,11 +376,6 @@ public class TileEntityPRC extends TileEntityBasicMachine implements IFluidHandl
@Override
public boolean canDrain(ForgeDirection from, Fluid fluid)
{
if(from == ForgeDirection.getOrientation(facing).getOpposite())
{
return inputFluidTank.getFluid() != null && inputFluidTank.getFluid().getFluid() == fluid;
}
return false;
}

View file

@ -0,0 +1,367 @@
package mekanism.common.tile;
import io.netty.buffer.ByteBuf;
import java.util.ArrayList;
import mekanism.api.Coord4D;
import mekanism.api.IConfigurable;
import mekanism.common.IActiveState;
import mekanism.common.ISustainedTank;
import mekanism.common.Mekanism;
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.PipeUtils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTank;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
public class TileEntityPortableTank extends TileEntityContainerBlock implements IActiveState, IConfigurable, IFluidHandler, ISustainedTank
{
public boolean isActive;
public boolean clientActive;
public FluidTank fluidTank = new FluidTank(14000);
public int updateDelay;
public TileEntityPortableTank()
{
super("PortableTank");
inventory = new ItemStack[2];
}
@Override
public boolean canSetFacing(int facing)
{
return false;
}
@Override
public void onUpdate()
{
if(worldObj.isRemote)
{
if(updateDelay > 0)
{
updateDelay--;
if(updateDelay == 0 && clientActive != isActive)
{
isActive = clientActive;
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
}
}
}
else {
if(inventory[0] != null)
{
manageInventory();
}
if(isActive)
{
activeEmit();
}
}
}
private void activeEmit()
{
if(fluidTank.getFluid() != null)
{
TileEntity tileEntity = Coord4D.get(this).getFromSide(ForgeDirection.DOWN).getTileEntity(worldObj);
if(tileEntity instanceof IFluidHandler)
{
FluidStack toDrain = new FluidStack(fluidTank.getFluid(), Math.min(100, fluidTank.getFluidAmount()));
fluidTank.drain(((IFluidHandler)tileEntity).fill(ForgeDirection.UP, toDrain, true), true);
}
}
}
private void manageInventory()
{
if(inventory[0] != null)
{
if(FluidContainerRegistry.isEmptyContainer(inventory[0]))
{
if(fluidTank.getFluid() != null && fluidTank.getFluid().amount >= FluidContainerRegistry.BUCKET_VOLUME)
{
ItemStack filled = FluidContainerRegistry.fillFluidContainer(fluidTank.getFluid(), inventory[0]);
if(filled != null)
{
if(inventory[1] == null || (inventory[1].isItemEqual(filled) && inventory[1].stackSize+1 <= filled.getMaxStackSize()))
{
inventory[0].stackSize--;
if(inventory[0].stackSize <= 0)
{
inventory[0] = null;
}
if(inventory[1] == null)
{
inventory[1] = filled;
}
else {
inventory[1].stackSize++;
}
fluidTank.drain(FluidContainerRegistry.getFluidForFilledItem(filled).amount, true);
}
}
}
}
else if(FluidContainerRegistry.isFilledContainer(inventory[0]))
{
FluidStack itemFluid = FluidContainerRegistry.getFluidForFilledItem(inventory[0]);
if((fluidTank.getFluid() == null && itemFluid.amount <= fluidTank.getCapacity()) || fluidTank.getFluid().amount+itemFluid.amount <= fluidTank.getCapacity())
{
if(fluidTank.getFluid() != null && !fluidTank.getFluid().isFluidEqual(itemFluid))
{
return;
}
ItemStack containerItem = inventory[0].getItem().getContainerItem(inventory[0]);
boolean filled = false;
if(containerItem != null)
{
if(inventory[1] == null || (inventory[1].isItemEqual(containerItem) && inventory[1].stackSize+1 <= containerItem.getMaxStackSize()))
{
inventory[0] = null;
if(inventory[1] == null)
{
inventory[1] = containerItem;
}
else {
inventory[1].stackSize++;
}
filled = true;
}
}
else {
inventory[0].stackSize--;
if(inventory[0].stackSize == 0)
{
inventory[0] = null;
}
filled = true;
}
if(filled)
{
fluidTank.fill(itemFluid, true);
}
}
}
}
}
@Override
public void writeToNBT(NBTTagCompound nbtTags)
{
super.writeToNBT(nbtTags);
nbtTags.setBoolean("isActive", isActive);
if(fluidTank.getFluid() != null)
{
nbtTags.setTag("fluidTank", fluidTank.writeToNBT(new NBTTagCompound()));
}
}
@Override
public void readFromNBT(NBTTagCompound nbtTags)
{
super.readFromNBT(nbtTags);
clientActive = isActive = nbtTags.getBoolean("isActive");
if(nbtTags.hasKey("fluidTank"))
{
fluidTank.readFromNBT(nbtTags.getCompoundTag("fluidTank"));
}
}
@Override
public void handlePacketData(ByteBuf dataStream)
{
super.handlePacketData(dataStream);
clientActive = dataStream.readBoolean();
if(dataStream.readInt() == 1)
{
fluidTank.setFluid(new FluidStack(dataStream.readInt(), dataStream.readInt()));
}
else {
fluidTank.setFluid(null);
}
if(updateDelay == 0 && clientActive != isActive)
{
updateDelay = Mekanism.UPDATE_DELAY;
isActive = clientActive;
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
}
}
@Override
public ArrayList getNetworkedData(ArrayList data)
{
super.getNetworkedData(data);
data.add(isActive);
if(fluidTank.getFluid() != null)
{
data.add(1);
data.add(fluidTank.getFluid().fluidID);
data.add(fluidTank.getFluid().amount);
}
else {
data.add(0);
}
return data;
}
@Override
public void setActive(boolean active)
{
isActive = active;
if(clientActive != active && updateDelay == 0)
{
Mekanism.packetHandler.sendToAll(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())));
updateDelay = 10;
clientActive = active;
}
}
@Override
public boolean getActive()
{
return isActive;
}
@Override
public boolean renderUpdate()
{
return false;
}
@Override
public boolean lightUpdate()
{
return true;
}
@Override
public boolean onSneakRightClick(EntityPlayer player, int side)
{
setActive(!getActive());
worldObj.playSoundEffect(xCoord, yCoord, zCoord, "random.click", 0.3F, 1);
return true;
}
@Override
public boolean onRightClick(EntityPlayer player, int side)
{
return false;
}
@Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
{
if(resource != null && canFill(from, resource.getFluid()))
{
return fluidTank.fill(resource, doFill);
}
return 0;
}
@Override
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain)
{
if(resource != null && canDrain(from, resource.getFluid()))
{
return fluidTank.drain(resource.amount, doDrain);
}
return null;
}
@Override
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
{
if(canDrain(from, null))
{
return fluidTank.drain(maxDrain, doDrain);
}
return null;
}
@Override
public boolean canFill(ForgeDirection from, Fluid fluid)
{
return from == ForgeDirection.UP && (fluidTank.getFluid() == null || fluidTank.getFluid().getFluid() == fluid);
}
@Override
public boolean canDrain(ForgeDirection from, Fluid fluid)
{
return !isActive && from == ForgeDirection.DOWN && (fluid == null || (fluidTank != null && fluidTank.getFluid().getFluid() == fluid));
}
@Override
public FluidTankInfo[] getTankInfo(ForgeDirection from)
{
if(from == ForgeDirection.UP || from == ForgeDirection.DOWN)
{
return new FluidTankInfo[] {fluidTank.getInfo()};
}
return PipeUtils.EMPTY;
}
@Override
public void setFluidStack(FluidStack fluidStack, Object... data)
{
fluidTank.setFluid(fluidStack);
}
@Override
public FluidStack getFluidStack(Object... data)
{
return fluidTank.getFluid();
}
@Override
public boolean hasTank(Object... data)
{
return true;
}
}

View file

@ -36,11 +36,11 @@ import net.minecraftforge.fluids.IFluidHandler;
public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock implements IActiveState, ISustainedTank, IFluidHandler, IGasHandler, ITubeConnection, IRedstoneControl
{
public GasTank gasTank = new GasTank(MAX_GAS);
public GasTank gasTank = new GasTank(MAX_FLUID);
public FluidTank fluidTank;
public FluidTank fluidTank = new FluidTank(MAX_FLUID);
public static final int MAX_GAS = 10000;
public static final int MAX_FLUID = 10000;
public int updateDelay;
@ -63,7 +63,6 @@ public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock imp
public TileEntityRotaryCondensentrator()
{
super("RotaryCondensentrator", MachineType.ROTARY_CONDENSENTRATOR.baseEnergy);
fluidTank = new FluidTank(10000);
inventory = new ItemStack[5];
}
@ -139,7 +138,7 @@ public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock imp
}
}
if(getEnergy() >= ENERGY_USAGE && MekanismUtils.canFunction(this) && isValidGas(gasTank.getGas()) && (fluidTank.getFluid() == null || (fluidTank.getFluid().amount < 10000 && gasEquals(gasTank.getGas(), fluidTank.getFluid()))))
if(getEnergy() >= ENERGY_USAGE && MekanismUtils.canFunction(this) && isValidGas(gasTank.getGas()) && (fluidTank.getFluid() == null || (fluidTank.getFluid().amount < MAX_FLUID && gasEquals(gasTank.getGas(), fluidTank.getFluid()))))
{
setActive(true);
fluidTank.fill(new FluidStack(gasTank.getGas().getGas().getFluid(), 1), true);
@ -179,7 +178,7 @@ public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock imp
{
FluidStack itemFluid = FluidContainerRegistry.getFluidForFilledItem(inventory[2]);
if((fluidTank.getFluid() == null && itemFluid.amount <= 10000) || fluidTank.getFluid().amount+itemFluid.amount <= 10000)
if((fluidTank.getFluid() == null && itemFluid.amount <= MAX_FLUID) || fluidTank.getFluid().amount+itemFluid.amount <= MAX_FLUID)
{
if(fluidTank.getFluid() != null && !fluidTank.getFluid().isFluidEqual(itemFluid))
{
@ -225,7 +224,7 @@ public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock imp
}
}
if(getEnergy() >= ENERGY_USAGE && MekanismUtils.canFunction(this) && isValidFluid(fluidTank.getFluid()) && (gasTank.getGas() == null || (gasTank.getStored() < MAX_GAS && gasEquals(gasTank.getGas(), fluidTank.getFluid()))))
if(getEnergy() >= ENERGY_USAGE && MekanismUtils.canFunction(this) && isValidFluid(fluidTank.getFluid()) && (gasTank.getGas() == null || (gasTank.getStored() < MAX_FLUID && gasEquals(gasTank.getGas(), fluidTank.getFluid()))))
{
setActive(true);
gasTank.receive(new GasStack(GasRegistry.getGas(fluidTank.getFluid().getFluid()), 1), true);
@ -393,12 +392,12 @@ public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock imp
public int getScaledFluidLevel(int i)
{
return fluidTank.getFluid() != null ? fluidTank.getFluid().amount*i / 10000 : 0;
return fluidTank.getFluid() != null ? fluidTank.getFluid().amount*i / MAX_FLUID : 0;
}
public int getScaledGasLevel(int i)
{
return gasTank.getGas() != null ? gasTank.getStored()*i / MAX_GAS : 0;
return gasTank.getGas() != null ? gasTank.getStored()*i / MAX_FLUID : 0;
}
@Override

View file

@ -7,8 +7,8 @@ import java.util.HashSet;
import java.util.Set;
import mekanism.api.Coord4D;
import mekanism.api.IConfigurable;
import mekanism.api.ISalinationSolar;
import mekanism.common.IConfigurable;
import mekanism.common.Mekanism;
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
import mekanism.common.tank.TankUpdateProtocol;

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB