mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-22 04:52:25 +00:00
Merge branch 'v9' into 1.8.9
This commit is contained in:
commit
62e7cc8f65
54 files changed
+992
-344
No files matched your search
@@ -0,0 +1,18 @@
|
||||
package mekanism.api;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
/**
|
||||
* Implement this class in your TileEntity if it can interact with Mekanism alloys.
|
||||
* @author aidancbrady
|
||||
*
|
||||
*/
|
||||
public interface IAlloyInteraction
|
||||
{
|
||||
/**
|
||||
* Called when a player right-clicks this block with an alloy.
|
||||
* @param player - the player right-clicking the block
|
||||
* @param tierOrdinal - the ordinal tier of the alloy (1 = advanced, 2 = elite, 3 = ultimate)
|
||||
*/
|
||||
public void onAlloyInteraction(EntityPlayer player, int tierOrdinal);
|
||||
}
|
||||
@@ -56,6 +56,9 @@ public class MekanismConfig
|
||||
public static int maxJetpackGas;
|
||||
public static int maxScubaGas;
|
||||
public static int maxFlamethrowerGas;
|
||||
public static int maxPumpRange;
|
||||
public static boolean pumpWaterSources;
|
||||
public static int maxPlenisherNodes;
|
||||
}
|
||||
|
||||
public static class client
|
||||
|
||||
@@ -54,15 +54,15 @@ public class GasNetwork extends DynamicNetwork<IGasHandler, GasNetwork>
|
||||
net.refGas = null;
|
||||
net.buffer = null;
|
||||
}
|
||||
} else
|
||||
{
|
||||
}
|
||||
else {
|
||||
if(net.buffer != null)
|
||||
{
|
||||
if(buffer == null)
|
||||
{
|
||||
buffer = net.buffer.copy();
|
||||
} else
|
||||
{
|
||||
}
|
||||
else {
|
||||
if(buffer.isGasEqual(net.buffer))
|
||||
{
|
||||
buffer.amount += net.buffer.amount;
|
||||
|
||||
@@ -2,6 +2,7 @@ package mekanism.api.gas;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@@ -20,16 +21,11 @@ import net.minecraft.util.EnumFacing;
|
||||
*/
|
||||
public final class GasTransmission
|
||||
{
|
||||
/**
|
||||
* Gets all the acceptors around a tile entity.
|
||||
* @param tileEntity - center tile entity
|
||||
* @return array of IGasAcceptors
|
||||
*/
|
||||
public static IGasHandler[] getConnectedAcceptors(TileEntity tileEntity)
|
||||
public static IGasHandler[] getConnectedAcceptors(TileEntity tileEntity, Collection<EnumFacing> sides)
|
||||
{
|
||||
IGasHandler[] acceptors = new IGasHandler[] {null, null, null, null, null, null};
|
||||
|
||||
for(EnumFacing orientation : EnumFacing.VALUES)
|
||||
for(EnumFacing orientation : sides)
|
||||
{
|
||||
TileEntity acceptor = Coord4D.get(tileEntity).offset(orientation).getTileEntity(tileEntity.getWorld());
|
||||
|
||||
@@ -41,6 +37,16 @@ public final class GasTransmission
|
||||
|
||||
return acceptors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all the acceptors around a tile entity.
|
||||
* @param tileEntity - center tile entity
|
||||
* @return array of IGasAcceptors
|
||||
*/
|
||||
public static IGasHandler[] getConnectedAcceptors(TileEntity tileEntity)
|
||||
{
|
||||
return getConnectedAcceptors(tileEntity, Arrays.asList(EnumFacing.VALUES));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all the tube connections around a tile entity.
|
||||
@@ -125,12 +131,12 @@ public final class GasTransmission
|
||||
|
||||
/**
|
||||
* Emits gas from a central block by splitting the received stack among the sides given.
|
||||
* @param sides - the list of sides to output from
|
||||
* @param stack - the stack to output
|
||||
* @param from - the TileEntity to output from
|
||||
* @param sides - the list of sides to output from
|
||||
* @return the amount of gas emitted
|
||||
*/
|
||||
public static int emit(List<EnumFacing> sides, GasStack stack, TileEntity from)
|
||||
public static int emit(GasStack stack, TileEntity from, Collection<EnumFacing> sides)
|
||||
{
|
||||
if(stack == null)
|
||||
{
|
||||
@@ -138,7 +144,7 @@ public final class GasTransmission
|
||||
}
|
||||
|
||||
List<IGasHandler> availableAcceptors = new ArrayList<IGasHandler>();
|
||||
IGasHandler[] possibleAcceptors = getConnectedAcceptors(from);
|
||||
IGasHandler[] possibleAcceptors = getConnectedAcceptors(from, sides);
|
||||
|
||||
for(int i = 0; i < possibleAcceptors.length; i++)
|
||||
{
|
||||
|
||||
@@ -5,24 +5,27 @@ import java.util.List;
|
||||
import mekanism.api.energy.IStrictEnergyStorage;
|
||||
import mekanism.api.util.ListUtils;
|
||||
import mekanism.client.gui.element.GuiEnergyGauge;
|
||||
import mekanism.client.gui.element.GuiEnergyInfo;
|
||||
import mekanism.client.gui.element.GuiRedstoneControl;
|
||||
import mekanism.client.gui.element.GuiSlot;
|
||||
import mekanism.client.gui.element.GuiEnergyGauge.IEnergyInfoHandler;
|
||||
import mekanism.client.gui.element.GuiEnergyInfo;
|
||||
import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler;
|
||||
import mekanism.client.gui.element.GuiRedstoneControl;
|
||||
import mekanism.client.gui.element.GuiSideConfigurationTab;
|
||||
import mekanism.client.gui.element.GuiSlot;
|
||||
import mekanism.client.gui.element.GuiSlot.SlotOverlay;
|
||||
import mekanism.client.gui.element.GuiSlot.SlotType;
|
||||
import mekanism.client.gui.element.GuiTransporterConfigTab;
|
||||
import mekanism.common.inventory.container.ContainerEnergyCube;
|
||||
import mekanism.common.tile.TileEntityEnergyCube;
|
||||
import mekanism.common.util.LangUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.MekanismUtils.ResourceType;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiEnergyCube extends GuiMekanism
|
||||
{
|
||||
@@ -33,6 +36,8 @@ public class GuiEnergyCube extends GuiMekanism
|
||||
super(tentity, new ContainerEnergyCube(inventory, tentity));
|
||||
tileEntity = tentity;
|
||||
guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiEnergyCube.png")));
|
||||
guiElements.add(new GuiSideConfigurationTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiEnergyCube.png")));
|
||||
guiElements.add(new GuiTransporterConfigTab(this, 34, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiEnergyCube.png")));
|
||||
guiElements.add(new GuiEnergyGauge(new IEnergyInfoHandler()
|
||||
{
|
||||
@Override
|
||||
@@ -51,8 +56,8 @@ public class GuiEnergyCube extends GuiMekanism
|
||||
LangUtils.localize("gui.maxOutput") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t");
|
||||
}
|
||||
}, this, MekanismUtils.getResource(ResourceType.GUI, "GuiEnergyCube.png")));
|
||||
guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiEnergyCube.png"), 16, 34).with(SlotOverlay.MINUS));
|
||||
guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiEnergyCube.png"), 142, 34).with(SlotOverlay.PLUS));
|
||||
guiElements.add(new GuiSlot(SlotType.INPUT, this, MekanismUtils.getResource(ResourceType.GUI, "GuiEnergyCube.png"), 16, 34).with(SlotOverlay.MINUS));
|
||||
guiElements.add(new GuiSlot(SlotType.OUTPUT, this, MekanismUtils.getResource(ResourceType.GUI, "GuiEnergyCube.png"), 142, 34).with(SlotOverlay.PLUS));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package mekanism.client.gui;
|
||||
|
||||
import mekanism.client.gui.element.GuiFluidGauge;
|
||||
import mekanism.client.gui.element.GuiFluidGauge.IFluidInfoHandler;
|
||||
import mekanism.client.gui.element.GuiGauge;
|
||||
import mekanism.client.gui.element.GuiPowerBar;
|
||||
import mekanism.client.gui.element.GuiSlot;
|
||||
import mekanism.client.gui.element.GuiFluidGauge.IFluidInfoHandler;
|
||||
import mekanism.client.gui.element.GuiSlot.SlotOverlay;
|
||||
import mekanism.client.gui.element.GuiSlot.SlotType;
|
||||
import mekanism.client.gui.element.GuiUpgradeTab;
|
||||
import mekanism.common.inventory.container.ContainerFluidicPlenisher;
|
||||
import mekanism.common.tile.TileEntityFluidicPlenisher;
|
||||
import mekanism.common.util.LangUtils;
|
||||
@@ -15,11 +16,12 @@ import mekanism.common.util.MekanismUtils.ResourceType;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiFluidicPlenisher extends GuiMekanism
|
||||
{
|
||||
@@ -43,7 +45,7 @@ public class GuiFluidicPlenisher extends GuiMekanism
|
||||
return tileEntity.fluidTank;
|
||||
}
|
||||
}, GuiGauge.Type.STANDARD, this, guiLocation, 6, 13));
|
||||
|
||||
guiElements.add(new GuiUpgradeTab(this, tileEntity, guiLocation));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,6 +4,11 @@ import java.util.ArrayList;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.client.gui.element.GuiRedstoneControl;
|
||||
import mekanism.client.gui.element.GuiSideConfigurationTab;
|
||||
import mekanism.client.gui.element.GuiSlot;
|
||||
import mekanism.client.gui.element.GuiSlot.SlotOverlay;
|
||||
import mekanism.client.gui.element.GuiSlot.SlotType;
|
||||
import mekanism.client.gui.element.GuiTransporterConfigTab;
|
||||
import mekanism.client.sound.SoundHandler;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.inventory.container.ContainerGasTank;
|
||||
@@ -29,6 +34,10 @@ public class GuiGasTank extends GuiMekanism
|
||||
super(tentity, new ContainerGasTank(inventory, tentity));
|
||||
tileEntity = tentity;
|
||||
guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiGasTank.png")));
|
||||
guiElements.add(new GuiSideConfigurationTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiGasTank.png")));
|
||||
guiElements.add(new GuiTransporterConfigTab(this, 34, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiGasTank.png")));
|
||||
guiElements.add(new GuiSlot(SlotType.OUTPUT, this, MekanismUtils.getResource(ResourceType.GUI, "GuiGasTank.png"), 7, 7).with(SlotOverlay.PLUS));
|
||||
guiElements.add(new GuiSlot(SlotType.INPUT, this, MekanismUtils.getResource(ResourceType.GUI, "GuiGasTank.png"), 7, 39).with(SlotOverlay.MINUS));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -54,8 +63,6 @@ public class GuiGasTank extends GuiMekanism
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY)
|
||||
{
|
||||
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
|
||||
|
||||
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiGasTank.png"));
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
int guiWidth = (width - xSize) / 2;
|
||||
@@ -70,6 +77,8 @@ public class GuiGasTank extends GuiMekanism
|
||||
int scale = (int)(((double)tileEntity.gasTank.getStored() / tileEntity.MAX_GAS) * 72);
|
||||
drawTexturedModalRect(guiWidth + 65, guiHeight + 17, 176, 0, scale, 10);
|
||||
}
|
||||
|
||||
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -9,13 +9,11 @@ import mekanism.api.Coord4D;
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.transmitters.TransmissionType;
|
||||
import mekanism.client.gui.element.GuiConfigTypeTab;
|
||||
import mekanism.client.gui.element.GuiElement;
|
||||
import mekanism.client.render.MekanismRenderer;
|
||||
import mekanism.client.sound.SoundHandler;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.SideData;
|
||||
import mekanism.common.base.ISideConfiguration;
|
||||
import mekanism.common.block.BlockMachine.MachineType;
|
||||
import mekanism.common.inventory.container.ContainerNull;
|
||||
import mekanism.common.network.PacketConfigurationUpdate.ConfigurationPacket;
|
||||
import mekanism.common.network.PacketConfigurationUpdate.ConfigurationUpdateMessage;
|
||||
@@ -220,7 +218,7 @@ public class GuiSideConfiguration extends GuiMekanism
|
||||
{
|
||||
if(xAxis >= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20)
|
||||
{
|
||||
int guiId = MachineType.get(tile.getBlockType(), tile.getBlockMetadata()).guiId;
|
||||
int guiId = Mekanism.proxy.getGuiId(tile.getBlockType(), tile.getBlockMetadata());
|
||||
SoundHandler.playSound("gui.button.press");
|
||||
Mekanism.packetHandler.sendToServer(new SimpleGuiMessage(Coord4D.get(tile), 0, guiId));
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ public class GuiTransporterConfig extends GuiMekanism
|
||||
{
|
||||
if(xAxis >= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20)
|
||||
{
|
||||
int guiId = MachineType.get(tile.getBlockType(), tile.getBlockMetadata()).guiId;
|
||||
int guiId = Mekanism.proxy.getGuiId(tile.getBlockType(), tile.getBlockMetadata());
|
||||
SoundHandler.playSound("gui.button.press");
|
||||
Mekanism.packetHandler.sendToServer(new SimpleGuiMessage(Coord4D.get(tile), 0, guiId));
|
||||
}
|
||||
|
||||
@@ -75,5 +75,7 @@ public class RenderEnergyCube extends TileEntitySpecialRenderer<TileEntityEnergy
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
//MekanismRenderer.machineRenderer.renderAModelAt(tileEntity, x, y, z, partialTick);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
package mekanism.client.render.tileentity;
|
||||
|
||||
import mekanism.client.model.ModelGasTank;
|
||||
import mekanism.client.render.MekanismRenderer;
|
||||
import mekanism.common.tile.TileEntityGasTank;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.MekanismUtils.ResourceType;
|
||||
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
@@ -35,5 +35,7 @@ public class RenderGasTank extends TileEntitySpecialRenderer<TileEntityGasTank>
|
||||
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
|
||||
model.render(0.0625F);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
//TODOMekanismRenderer.machineRenderer.renderAModelAt(tileEntity, x, y, z, partialTick);
|
||||
}
|
||||
}
|
||||
@@ -108,6 +108,7 @@ import mekanism.common.tile.TileEntitySolarEvaporationController;
|
||||
import mekanism.common.tile.TileEntitySolarNeutronActivator;
|
||||
import mekanism.common.tile.TileEntityStructuralGlass;
|
||||
import mekanism.common.tile.TileEntityTeleporter;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Blocks;
|
||||
@@ -267,6 +268,9 @@ public class CommonProxy implements IGuiProvider
|
||||
general.maxJetpackGas = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "MaxJetpackGas", 24000).getInt();
|
||||
general.maxScubaGas = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "MaxScubaGas", 24000).getInt();
|
||||
general.maxFlamethrowerGas = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "MaxFlamethrowerGas", 24000).getInt();
|
||||
general.maxPumpRange = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "MaxPumpRange", 80).getInt();
|
||||
general.pumpWaterSources = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "PumpWaterSources", false).getBoolean();
|
||||
general.maxPlenisherNodes = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "MaxPlenisherNodes", 4000).getInt();
|
||||
|
||||
general.blacklistIC2 = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "BlacklistIC2Power", false).getBoolean();
|
||||
general.blacklistRF = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "BlacklistRFPower", false).getBoolean();
|
||||
@@ -637,6 +641,24 @@ public class CommonProxy implements IGuiProvider
|
||||
{
|
||||
return context.getServerHandler().playerEntity;
|
||||
}
|
||||
|
||||
public int getGuiId(Block block, int metadata)
|
||||
{
|
||||
if(MachineType.get(block, metadata) != null)
|
||||
{
|
||||
return MachineType.get(block, metadata).guiId;
|
||||
}
|
||||
else if(block == MekanismBlocks.GasTank)
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
else if(block == MekanismBlocks.EnergyCube)
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void renderLaser(World world, Pos3D from, Pos3D to, EnumFacing direction, double energy) {}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package mekanism.common;
|
||||
|
||||
import mekanism.common.item.ItemAlloy;
|
||||
import mekanism.common.item.ItemAtomicDisassembler;
|
||||
import mekanism.common.item.ItemBalloon;
|
||||
import mekanism.common.item.ItemClump;
|
||||
@@ -43,9 +44,9 @@ import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder;
|
||||
@ObjectHolder("Mekanism")
|
||||
public class MekanismItems
|
||||
{
|
||||
public static final Item EnrichedAlloy = new ItemMekanism().setUnlocalizedName("EnrichedAlloy");
|
||||
public static final Item ReinforcedAlloy = new ItemMekanism().setUnlocalizedName("ReinforcedAlloy");
|
||||
public static final Item AtomicAlloy = new ItemMekanism().setUnlocalizedName("AtomicAlloy");
|
||||
public static final Item EnrichedAlloy = new ItemAlloy().setUnlocalizedName("EnrichedAlloy");
|
||||
public static final Item ReinforcedAlloy = new ItemAlloy().setUnlocalizedName("ReinforcedAlloy");
|
||||
public static final Item AtomicAlloy = new ItemAlloy().setUnlocalizedName("AtomicAlloy");
|
||||
public static final Item TeleportationCore = new ItemMekanism().setUnlocalizedName("TeleportationCore");
|
||||
public static final Item ElectrolyticCore = new ItemMekanism().setUnlocalizedName("ElectrolyticCore");
|
||||
public static final Item Substrate = new ItemMekanism().setUnlocalizedName("Substrate");
|
||||
|
||||
@@ -18,11 +18,11 @@ public class SideData
|
||||
/** The name of this SideData */
|
||||
public String name;
|
||||
|
||||
/** Int[] of available side slots, can be used for items, gases, or items */
|
||||
/** int[] of available side slots, can be used for items, gases, or items */
|
||||
public int[] availableSlots;
|
||||
|
||||
/** EnergyState representing this SideData */
|
||||
public EnergyState energyState;
|
||||
/** IOState representing this SideData */
|
||||
public IOState ioState;
|
||||
|
||||
public SideData(String n, EnumColor colour, int[] slots)
|
||||
{
|
||||
@@ -31,11 +31,11 @@ public class SideData
|
||||
availableSlots = slots;
|
||||
}
|
||||
|
||||
public SideData(String n, EnumColor colour, EnergyState state)
|
||||
public SideData(String n, EnumColor colour, IOState state)
|
||||
{
|
||||
name = n;
|
||||
color = colour;
|
||||
energyState = state;
|
||||
ioState = state;
|
||||
}
|
||||
|
||||
public String localize()
|
||||
@@ -87,7 +87,7 @@ public class SideData
|
||||
return (GasTank)tanks[0];
|
||||
}
|
||||
|
||||
public static enum EnergyState
|
||||
public static enum IOState
|
||||
{
|
||||
INPUT,
|
||||
OUTPUT,
|
||||
|
||||
@@ -72,7 +72,6 @@ public class SynchronizedBoilerData extends SynchronizedData<SynchronizedBoilerD
|
||||
@Override
|
||||
public double applyTemperatureChange()
|
||||
{
|
||||
|
||||
if(temperature < 100 + IHeatTransfer.AMBIENT_TEMP)
|
||||
{
|
||||
double temperatureDeficit = 100 + IHeatTransfer.AMBIENT_TEMP - temperature;
|
||||
@@ -81,23 +80,26 @@ public class SynchronizedBoilerData extends SynchronizedData<SynchronizedBoilerD
|
||||
heatToAbsorb -= heatProvided;
|
||||
temperature += heatProvided / (volume * heatCapacity * 16);
|
||||
}
|
||||
|
||||
if(temperature >= 100 + IHeatTransfer.AMBIENT_TEMP && waterStored != null)
|
||||
{
|
||||
int amountToBoil = (int)Math.floor(heatToAbsorb / enthalpyOfVaporization);
|
||||
amountToBoil = Math.min(amountToBoil, waterStored.amount);
|
||||
waterStored.amount -= amountToBoil;
|
||||
|
||||
if(steamStored == null)
|
||||
{
|
||||
steamStored = new FluidStack(FluidRegistry.getFluid("steam"), amountToBoil);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
steamStored.amount += amountToBoil;
|
||||
}
|
||||
|
||||
heatToAbsorb -= amountToBoil * enthalpyOfVaporization;
|
||||
}
|
||||
|
||||
heatToAbsorb *= 0.8;
|
||||
|
||||
return temperature;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package mekanism.common.item;
|
||||
|
||||
import mekanism.api.IAlloyInteraction;
|
||||
import mekanism.common.MekanismItems;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemAlloy extends ItemMekanism
|
||||
{
|
||||
public ItemAlloy()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
|
||||
if(tile instanceof IAlloyInteraction)
|
||||
{
|
||||
if(!world.isRemote)
|
||||
{
|
||||
int ordinal = stack.getItem() == MekanismItems.EnrichedAlloy? 1 : (stack.getItem() == MekanismItems.ReinforcedAlloy ? 2 : 3);
|
||||
((IAlloyInteraction)tile).onAlloyInteraction(player, ordinal);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -475,11 +475,11 @@ public abstract class UpdateProtocol<T extends SynchronizedData<T>>
|
||||
//TODO perhaps drop from pointer?
|
||||
|
||||
cache.apply((T)structureFound);
|
||||
|
||||
onFormed();
|
||||
|
||||
structureFound.inventoryID = idToUse;
|
||||
|
||||
onFormed();
|
||||
|
||||
List<IStructuralMultiblock> structures = new ArrayList<IStructuralMultiblock>();
|
||||
Coord4D toUse = null;
|
||||
|
||||
|
||||
@@ -64,14 +64,6 @@ public class ItemPartTransmitter extends JItemMultiPart
|
||||
networks.add(((ITransmitterTile)tile).getTransmitter().getTransmitterNetwork());
|
||||
}
|
||||
}
|
||||
|
||||
if(networks.size() > 0)
|
||||
{
|
||||
/*if(!networks.iterator().next().canMerge(networks))
|
||||
{
|
||||
return null;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
return PartTransmitter.getPartType(TransmitterType.values()[getDamage(stack)]);
|
||||
|
||||
@@ -3,11 +3,8 @@ package mekanism.common.multipart;
|
||||
import mekanism.api.IHeatTransfer;
|
||||
import mekanism.common.HeatNetwork;
|
||||
import mekanism.common.util.HeatUtils;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import codechicken.lib.colour.Colour;
|
||||
import codechicken.lib.colour.ColourRGBA;
|
||||
|
||||
/**
|
||||
@@ -61,11 +58,13 @@ public class MultipartHeatTransmitter extends MultipartTransmitter<IHeatTransfer
|
||||
{
|
||||
temperature += material.inverseHeatCapacity * heatToAbsorb;
|
||||
heatToAbsorb = 0;
|
||||
|
||||
if(Math.abs(temperature - clientTemperature) > (temperature / 100))
|
||||
{
|
||||
clientTemperature = temperature;
|
||||
getPart().sendTemp();
|
||||
}
|
||||
|
||||
return temperature;
|
||||
}
|
||||
|
||||
@@ -81,11 +80,13 @@ public class MultipartHeatTransmitter extends MultipartTransmitter<IHeatTransfer
|
||||
if(getPart().connectionMapContainsSide(getPart().getAllCurrentConnections(), side))
|
||||
{
|
||||
TileEntity adj = coord().offset(side).getTileEntity(world());
|
||||
|
||||
if(adj instanceof IHeatTransfer)
|
||||
{
|
||||
return (IHeatTransfer)adj;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ public class MultipartMekanism implements IPartFactory
|
||||
MultipartGenerator.registerPassThroughInterface("mekanism.api.IHeatTransfer");
|
||||
MultipartGenerator.registerPassThroughInterface("mekanism.api.transmitters.IBlockableConnection");
|
||||
MultipartGenerator.registerPassThroughInterface("mekanism.api.transmitters.ITransmitterTile");
|
||||
MultipartGenerator.registerPassThroughInterface("mekanism.api.IAlloyInteraction");
|
||||
MultipartGenerator.registerPassThroughInterface("mekanism.common.base.ITransporterTile");
|
||||
MultipartGenerator.registerPassThroughInterface("mekanism.common.base.ILogisticalTransporter");
|
||||
MultipartGenerator.registerPassThroughInterface("mekanism.common.base.ITileNetwork");
|
||||
|
||||
@@ -13,6 +13,7 @@ import mekanism.client.render.RenderPartTransmitter;
|
||||
import mekanism.common.InventoryNetwork;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.Tier;
|
||||
import mekanism.common.Tier.BaseTier;
|
||||
import mekanism.common.Tier.TransporterTier;
|
||||
import mekanism.common.base.ILogisticalTransporter;
|
||||
import mekanism.common.base.ITransporterTile;
|
||||
@@ -36,6 +37,8 @@ import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.common.util.Constants.NBT;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import codechicken.lib.data.MCDataInput;
|
||||
import codechicken.lib.data.MCDataOutput;
|
||||
import codechicken.lib.vec.Vector3;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
@@ -448,4 +451,36 @@ public class PartLogisticalTransporter extends PartTransmitter<IInventory, Inven
|
||||
{
|
||||
return (double)TransporterTier.ULTIMATE.speed / (double)tier.speed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean upgrade(int tierOrdinal)
|
||||
{
|
||||
if(tier.ordinal() < BaseTier.ULTIMATE.ordinal() && tierOrdinal == tier.ordinal()+1)
|
||||
{
|
||||
tier = TransporterTier.values()[tier.ordinal()+1];
|
||||
|
||||
markDirtyTransmitters();
|
||||
sendDesc = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readDesc(MCDataInput packet)
|
||||
{
|
||||
tier = TransporterTier.values()[packet.readInt()];
|
||||
|
||||
super.readDesc(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDesc(MCDataOutput packet)
|
||||
{
|
||||
packet.writeInt(tier.ordinal());
|
||||
|
||||
super.writeDesc(packet);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,13 @@
|
||||
package mekanism.common.multipart;
|
||||
|
||||
import codechicken.lib.vec.Vector3;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import java.util.Collection;
|
||||
|
||||
import mekanism.api.transmitters.TransmissionType;
|
||||
import mekanism.client.render.RenderPartTransmitter;
|
||||
import mekanism.common.FluidNetwork;
|
||||
import mekanism.common.Tier;
|
||||
import mekanism.common.Tier.BaseTier;
|
||||
import mekanism.common.Tier.PipeTier;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.PipeUtils;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
@@ -14,9 +15,17 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.*;
|
||||
|
||||
import java.util.Collection;
|
||||
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;
|
||||
import codechicken.lib.data.MCDataInput;
|
||||
import codechicken.lib.data.MCDataOutput;
|
||||
import codechicken.lib.vec.Vector3;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class PartMechanicalPipe extends PartTransmitter<IFluidHandler, FluidNetwork> implements IFluidHandler
|
||||
{
|
||||
@@ -307,4 +316,36 @@ public class PartMechanicalPipe extends PartTransmitter<IFluidHandler, FluidNetw
|
||||
return buffer.fill(fluid, doEmit);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean upgrade(int tierOrdinal)
|
||||
{
|
||||
if(tier.ordinal() < BaseTier.ULTIMATE.ordinal() && tierOrdinal == tier.ordinal()+1)
|
||||
{
|
||||
tier = PipeTier.values()[tier.ordinal()+1];
|
||||
|
||||
markDirtyTransmitters();
|
||||
sendDesc = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readDesc(MCDataInput packet)
|
||||
{
|
||||
tier = PipeTier.values()[packet.readInt()];
|
||||
|
||||
super.readDesc(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDesc(MCDataOutput packet)
|
||||
{
|
||||
packet.writeInt(tier.ordinal());
|
||||
|
||||
super.writeDesc(packet);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,17 @@
|
||||
package mekanism.common.multipart;
|
||||
|
||||
import codechicken.lib.vec.Vector3;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import mekanism.api.gas.*;
|
||||
import java.util.Collection;
|
||||
|
||||
import mekanism.api.gas.Gas;
|
||||
import mekanism.api.gas.GasNetwork;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.api.gas.GasTank;
|
||||
import mekanism.api.gas.GasTransmission;
|
||||
import mekanism.api.gas.IGasHandler;
|
||||
import mekanism.api.transmitters.TransmissionType;
|
||||
import mekanism.client.render.RenderPartTransmitter;
|
||||
import mekanism.common.Tier;
|
||||
import mekanism.common.Tier.BaseTier;
|
||||
import mekanism.common.Tier.TubeTier;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
@@ -14,8 +19,11 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.Collection;
|
||||
import codechicken.lib.data.MCDataInput;
|
||||
import codechicken.lib.data.MCDataOutput;
|
||||
import codechicken.lib.vec.Vector3;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class PartPressurizedTube extends PartTransmitter<IGasHandler, GasNetwork> implements IGasHandler
|
||||
{
|
||||
@@ -315,4 +323,36 @@ public class PartPressurizedTube extends PartTransmitter<IGasHandler, GasNetwork
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean upgrade(int tierOrdinal)
|
||||
{
|
||||
if(tier.ordinal() < BaseTier.ULTIMATE.ordinal() && tierOrdinal == tier.ordinal()+1)
|
||||
{
|
||||
tier = TubeTier.values()[tier.ordinal()+1];
|
||||
|
||||
markDirtyTransmitters();
|
||||
sendDesc = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readDesc(MCDataInput packet)
|
||||
{
|
||||
tier = TubeTier.values()[packet.readInt()];
|
||||
|
||||
super.readDesc(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDesc(MCDataOutput packet)
|
||||
{
|
||||
packet.writeInt(tier.ordinal());
|
||||
|
||||
super.writeDesc(packet);
|
||||
}
|
||||
}
|
||||
@@ -633,7 +633,6 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart,
|
||||
|
||||
currentTransmitterConnections = setConnectionBit(currentTransmitterConnections, possibleTransmitter, side);
|
||||
currentAcceptorConnections = setConnectionBit(currentAcceptorConnections, possibleAcceptor, side);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -679,6 +678,7 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart,
|
||||
{
|
||||
boolean prevPowered = redstonePowered;
|
||||
refreshConnections();
|
||||
|
||||
if(prevPowered != redstonePowered)
|
||||
{
|
||||
markDirtyTransmitters();
|
||||
@@ -690,8 +690,10 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart,
|
||||
public void onPartChanged(TMultiPart part)
|
||||
{
|
||||
super.onPartChanged(part);
|
||||
|
||||
byte transmittersBefore = currentTransmitterConnections;
|
||||
refreshConnections();
|
||||
|
||||
if(transmittersBefore != currentTransmitterConnections)
|
||||
{
|
||||
markDirtyTransmitters();
|
||||
|
||||
@@ -1,15 +1,22 @@
|
||||
package mekanism.common.multipart;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedHashSet;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.IAlloyInteraction;
|
||||
import mekanism.api.transmitters.DynamicNetwork;
|
||||
import mekanism.api.transmitters.DynamicNetwork.NetworkClientRequest;
|
||||
import mekanism.api.transmitters.IGridTransmitter;
|
||||
import mekanism.api.transmitters.ITransmitterTile;
|
||||
import mekanism.api.transmitters.TransmitterNetworkRegistry;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public abstract class PartTransmitter<A, N extends DynamicNetwork<A, N>> extends PartSidedPipe implements ITransmitterTile<A, N>
|
||||
public abstract class PartTransmitter<A, N extends DynamicNetwork<A, N>> extends PartSidedPipe implements ITransmitterTile<A, N>, IAlloyInteraction
|
||||
{
|
||||
public MultipartTransmitter<A, N> transmitterDelegate;
|
||||
|
||||
@@ -77,12 +84,6 @@ public abstract class PartTransmitter<A, N extends DynamicNetwork<A, N>> extends
|
||||
super.preRemove();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborTileChanged(int side, boolean weak)
|
||||
{
|
||||
super.onNeighborTileChanged(side, weak);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirtyTransmitters()
|
||||
{
|
||||
@@ -116,6 +117,71 @@ public abstract class PartTransmitter<A, N extends DynamicNetwork<A, N>> extends
|
||||
|
||||
return connectionMapContainsSide(currentAcceptorConnections, side) ? (A)cachedAcceptors[side.ordinal()] : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAlloyInteraction(EntityPlayer player, int tierOrdinal)
|
||||
{
|
||||
if(getTransmitter().hasTransmitterNetwork())
|
||||
{
|
||||
int upgraded = 0;
|
||||
Object[] array = ((LinkedHashSet)getTransmitter().getTransmitterNetwork().transmitters.clone()).toArray();
|
||||
|
||||
Arrays.sort(array, new Comparator() {
|
||||
@Override
|
||||
public int compare(Object o1, Object o2)
|
||||
{
|
||||
if(o1 instanceof IGridTransmitter && o2 instanceof IGridTransmitter)
|
||||
{
|
||||
Coord4D thisCoord = Coord4D.get(tile());
|
||||
|
||||
Coord4D o1Coord = ((IGridTransmitter)o1).coord();
|
||||
Coord4D o2Coord = ((IGridTransmitter)o2).coord();
|
||||
|
||||
return o1Coord.distanceTo(thisCoord) > o2Coord.distanceTo(thisCoord) ? 1 :
|
||||
(o1Coord.distanceTo(thisCoord) < o2Coord.distanceTo(thisCoord) ? -1 : 0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
|
||||
for(Object iter : array)
|
||||
{
|
||||
if(iter instanceof MultipartTransmitter)
|
||||
{
|
||||
PartTransmitter t = ((MultipartTransmitter)iter).containingPart;
|
||||
|
||||
if(t.upgrade(tierOrdinal))
|
||||
{
|
||||
upgraded++;
|
||||
|
||||
if(upgraded == 8)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(upgraded > 0)
|
||||
{
|
||||
if(!player.capabilities.isCreativeMode)
|
||||
{
|
||||
player.getCurrentEquippedItem().stackSize--;
|
||||
|
||||
if(player.getCurrentEquippedItem().stackSize == 0)
|
||||
{
|
||||
player.setCurrentItemOrArmor(0, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean upgrade(int tierOrdinal)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public abstract int getCapacity();
|
||||
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
package mekanism.common.multipart;
|
||||
|
||||
import codechicken.lib.vec.Vector3;
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
import cofh.api.energy.IEnergyProvider;
|
||||
import net.minecraftforge.fml.common.Optional.Interface;
|
||||
import net.minecraftforge.fml.common.Optional.InterfaceList;
|
||||
import net.minecraftforge.fml.common.Optional.Method;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import ic2.api.energy.tile.IEnergySource;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import mekanism.api.MekanismConfig.client;
|
||||
import mekanism.api.MekanismConfig.general;
|
||||
import mekanism.api.energy.EnergyStack;
|
||||
@@ -19,6 +15,8 @@ import mekanism.api.transmitters.TransmissionType;
|
||||
import mekanism.client.render.RenderPartTransmitter;
|
||||
import mekanism.common.EnergyNetwork;
|
||||
import mekanism.common.Tier;
|
||||
import mekanism.common.Tier.BaseTier;
|
||||
import mekanism.common.Tier.CableTier;
|
||||
import mekanism.common.base.EnergyAcceptorWrapper;
|
||||
import mekanism.common.util.CableUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
@@ -27,9 +25,16 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import codechicken.lib.data.MCDataInput;
|
||||
import codechicken.lib.data.MCDataOutput;
|
||||
import codechicken.lib.vec.Vector3;
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
import cofh.api.energy.IEnergyProvider;
|
||||
import net.minecraftforge.fml.common.Optional.Interface;
|
||||
import net.minecraftforge.fml.common.Optional.InterfaceList;
|
||||
import net.minecraftforge.fml.common.Optional.Method;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@InterfaceList({
|
||||
@Interface(iface = "cofh.api.energy.IEnergyHandler", modid = "CoFHCore"),
|
||||
@@ -184,7 +189,7 @@ public class PartUniversalCable extends PartTransmitter<EnergyAcceptorWrapper, E
|
||||
|
||||
public static void registerIcons(IIconRegister register)
|
||||
{
|
||||
cableIcons.registerCenterIcons(register, new String[]{"UniversalCableBasic", "UniversalCableAdvanced",
|
||||
cableIcons.registerCenterIcons(register, new String[] {"UniversalCableBasic", "UniversalCableAdvanced",
|
||||
"UniversalCableElite", "UniversalCableUltimate"});
|
||||
cableIcons.registerSideIcons(register, new String[] {"SmallTransmitterVerticalBasic", "SmallTransmitterVerticalAdvanced", "SmallTransmitterVerticalElite", "SmallTransmitterVerticalUltimate",
|
||||
"SmallTransmitterHorizontalBasic", "SmallTransmitterHorizontalAdvanced", "SmallTransmitterHorizontalElite", "SmallTransmitterHorizontalUltimate"});
|
||||
@@ -397,4 +402,36 @@ public class PartUniversalCable extends PartTransmitter<EnergyAcceptorWrapper, E
|
||||
|
||||
return connectionMapContainsSide(currentAcceptorConnections, side) ? EnergyAcceptorWrapper.get(cachedAcceptors[side.ordinal()]) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean upgrade(int tierOrdinal)
|
||||
{
|
||||
if(tier.ordinal() < BaseTier.ULTIMATE.ordinal() && tierOrdinal == tier.ordinal()+1)
|
||||
{
|
||||
tier = CableTier.values()[tier.ordinal()+1];
|
||||
|
||||
markDirtyTransmitters();
|
||||
sendDesc = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readDesc(MCDataInput packet)
|
||||
{
|
||||
tier = CableTier.values()[packet.readInt()];
|
||||
|
||||
super.readDesc(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDesc(MCDataOutput packet)
|
||||
{
|
||||
packet.writeInt(tier.ordinal());
|
||||
|
||||
super.writeDesc(packet);
|
||||
}
|
||||
}
|
||||
@@ -49,7 +49,7 @@ public class PacketDataRequest implements IMessageHandler<DataRequestMessage, IM
|
||||
}
|
||||
}
|
||||
|
||||
Mekanism.packetHandler.sendTo(new TileEntityMessage(Coord4D.get(tileEntity), ((ITileNetwork)tileEntity).getNetworkedData(new ArrayList())), (EntityPlayerMP)player);
|
||||
Mekanism.packetHandler.sendTo(new TileEntityMessage(Coord4D.get(tileEntity), ((ITileNetwork)tileEntity).getNetworkedData(new ArrayList<Object>())), (EntityPlayerMP)player);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -1,12 +1,23 @@
|
||||
package mekanism.common.tile;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.Range4D;
|
||||
import mekanism.api.gas.*;
|
||||
import mekanism.api.gas.Gas;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.api.gas.GasTank;
|
||||
import mekanism.api.gas.IGasHandler;
|
||||
import mekanism.api.gas.ITubeConnection;
|
||||
import mekanism.api.transmitters.TransmissionType;
|
||||
import mekanism.common.*;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.MekanismBlocks;
|
||||
import mekanism.common.MekanismItems;
|
||||
import mekanism.common.SideData;
|
||||
import mekanism.common.Upgrade;
|
||||
import mekanism.common.base.IFactory.RecipeType;
|
||||
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
import mekanism.common.recipe.RecipeHandler;
|
||||
@@ -26,8 +37,6 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public abstract class TileEntityAdvancedElectricMachine<RECIPE extends AdvancedMachineRecipe<RECIPE>> extends TileEntityBasicMachine<AdvancedMachineInput, ItemStackOutput, RECIPE> implements IGasHandler, ITubeConnection
|
||||
{
|
||||
/** How much secondary energy (fuel) this machine uses per tick, not including upgrades. */
|
||||
@@ -68,7 +77,7 @@ public abstract class TileEntityAdvancedElectricMachine<RECIPE extends AdvancedM
|
||||
configComponent.addOutput(TransmissionType.ITEM, new SideData("Energy", EnumColor.DARK_GREEN, new int[] {3}));
|
||||
|
||||
configComponent.setConfig(TransmissionType.ITEM, new byte[] {2, 1, 0, 4, 0, 3});
|
||||
configComponent.setInputEnergyConfig();
|
||||
configComponent.setInputConfig(TransmissionType.ENERGY);
|
||||
|
||||
gasTank = new GasTank(MAX_GAS);
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ public class TileEntityAdvancedFactory extends TileEntityFactory
|
||||
configComponent.fillConfig(TransmissionType.GAS, 1);
|
||||
configComponent.setCanEject(TransmissionType.GAS, false);
|
||||
|
||||
configComponent.setInputEnergyConfig();
|
||||
configComponent.setInputConfig(TransmissionType.ENERGY);
|
||||
|
||||
upgradeComponent = new TileComponentUpgrade(this, 0);
|
||||
ejectorComponent = new TileComponentEjector(this);
|
||||
|
||||
@@ -81,7 +81,7 @@ public abstract class TileEntityBasicBlock extends TileEntity implements IWrench
|
||||
{
|
||||
for(EntityPlayer player : playersUsing)
|
||||
{
|
||||
Mekanism.packetHandler.sendTo(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), (EntityPlayerMP)player);
|
||||
Mekanism.packetHandler.sendTo(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList<Object>())), (EntityPlayerMP)player);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -128,7 +128,7 @@ public abstract class TileEntityBasicBlock extends TileEntity implements IWrench
|
||||
@Override
|
||||
public ArrayList getNetworkedData(ArrayList<Object> data)
|
||||
{
|
||||
data.add(facing);
|
||||
data.add(facing == null ? -1 : facing.ordinal());
|
||||
data.add(redstone);
|
||||
|
||||
for(ITileComponent component : components)
|
||||
@@ -174,7 +174,7 @@ public abstract class TileEntityBasicBlock extends TileEntity implements IWrench
|
||||
{
|
||||
super.writeToNBT(nbtTags);
|
||||
|
||||
nbtTags.setInteger("facing", facing.ordinal());
|
||||
nbtTags.setInteger("facing", facing == null ? -1 : facing.ordinal());
|
||||
nbtTags.setBoolean("redstone", redstone);
|
||||
|
||||
for(ITileComponent component : components)
|
||||
|
||||
@@ -34,7 +34,7 @@ public abstract class TileEntityChanceMachine<RECIPE extends ChanceMachineRecipe
|
||||
configComponent.addOutput(TransmissionType.ITEM, new SideData("Output", EnumColor.DARK_BLUE, new int[] {2, 4}));
|
||||
|
||||
configComponent.setConfig(TransmissionType.ITEM, new byte[] {2, 1, 0, 0, 0, 3});
|
||||
configComponent.setInputEnergyConfig();
|
||||
configComponent.setInputConfig(TransmissionType.ENERGY);
|
||||
|
||||
inventory = new ItemStack[5];
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ public class TileEntityChemicalCrystallizer extends TileEntityNoisyElectricBlock
|
||||
configComponent.setConfig(TransmissionType.GAS, new byte[] {0, 0, 0, 0, 1, 0});
|
||||
configComponent.setCanEject(TransmissionType.GAS, false);
|
||||
|
||||
configComponent.setInputEnergyConfig();
|
||||
configComponent.setInputConfig(TransmissionType.ENERGY);
|
||||
|
||||
inventory = new ItemStack[4];
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ public abstract class TileEntityElectricMachine<RECIPE extends BasicMachineRecip
|
||||
configComponent.addOutput(TransmissionType.ITEM, new SideData("Output", EnumColor.DARK_BLUE, new int[] {2}));
|
||||
|
||||
configComponent.setConfig(TransmissionType.ITEM, new byte[] {2, 1, 0, 0, 0, 3});
|
||||
configComponent.setInputEnergyConfig();
|
||||
configComponent.setInputConfig(TransmissionType.ENERGY);
|
||||
|
||||
inventory = new ItemStack[4];
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import java.util.Set;
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.IConfigurable;
|
||||
import mekanism.api.MekanismConfig.general;
|
||||
import mekanism.api.MekanismConfig.usage;
|
||||
import mekanism.common.Upgrade;
|
||||
import mekanism.common.base.IRedstoneControl;
|
||||
@@ -27,6 +28,7 @@ import mekanism.common.util.LangUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.PipeUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
@@ -51,6 +53,21 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
|
||||
|
||||
/** The type of fluid this pump is pumping */
|
||||
public Fluid activeType;
|
||||
|
||||
public boolean suckedLastOperation;
|
||||
|
||||
/** How much energy this machine consumes per-tick. */
|
||||
public double BASE_ENERGY_PER_TICK = usage.electricPumpUsage;
|
||||
|
||||
public double energyPerTick = BASE_ENERGY_PER_TICK;
|
||||
|
||||
/** How many ticks it takes to run an operation. */
|
||||
public int BASE_TICKS_REQUIRED = 20;
|
||||
|
||||
public int ticksRequired = BASE_TICKS_REQUIRED;
|
||||
|
||||
/** How many ticks this machine has been operating for. */
|
||||
public int operatingTicks;
|
||||
|
||||
/** The nodes that have full sources near them or in them */
|
||||
public Set<Coord4D> recurringNodes = new HashSet<Coord4D>();
|
||||
@@ -65,7 +82,6 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
|
||||
super("ElectricPump", 10000);
|
||||
inventory = new ItemStack[4];
|
||||
|
||||
upgradeComponent.clearSupportedTypes();
|
||||
upgradeComponent.setSupported(Upgrade.FILTER);
|
||||
}
|
||||
|
||||
@@ -136,27 +152,47 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!worldObj.isRemote && ticker % 20 == 0)
|
||||
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
if(MekanismUtils.canFunction(this))
|
||||
if(MekanismUtils.canFunction(this) && getEnergy() >= energyPerTick)
|
||||
{
|
||||
if(getEnergy() >= usage.electricPumpUsage && (fluidTank.getFluid() == null || fluidTank.getFluid().amount + FluidContainerRegistry.BUCKET_VOLUME <= fluidTank.getCapacity()))
|
||||
if(suckedLastOperation)
|
||||
{
|
||||
if(!suck(true))
|
||||
setEnergy(getEnergy() - energyPerTick);
|
||||
}
|
||||
|
||||
if((operatingTicks + 1) < ticksRequired)
|
||||
{
|
||||
operatingTicks++;
|
||||
}
|
||||
else {
|
||||
if(fluidTank.getFluid() == null || fluidTank.getFluid().amount + FluidContainerRegistry.BUCKET_VOLUME <= fluidTank.getCapacity())
|
||||
{
|
||||
reset();
|
||||
if(!suck(true))
|
||||
{
|
||||
suckedLastOperation = false;
|
||||
reset();
|
||||
}
|
||||
else {
|
||||
suckedLastOperation = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
suckedLastOperation = false;
|
||||
}
|
||||
|
||||
operatingTicks = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
ticker--;
|
||||
suckedLastOperation = false;
|
||||
}
|
||||
}
|
||||
|
||||
super.onUpdate();
|
||||
|
||||
if(fluidTank.getFluid() != null)
|
||||
if(!worldObj.isRemote && fluidTank.getFluid() != null)
|
||||
{
|
||||
for(EnumFacing orientation : EnumFacing.VALUES)
|
||||
{
|
||||
@@ -164,7 +200,7 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
|
||||
|
||||
if(tileEntity instanceof IFluidHandler)
|
||||
{
|
||||
FluidStack toDrain = new FluidStack(fluidTank.getFluid(), Math.min(100, fluidTank.getFluidAmount()));
|
||||
FluidStack toDrain = new FluidStack(fluidTank.getFluid(), Math.min(256*upgradeComponent.getUpgrades(Upgrade.SPEED), fluidTank.getFluidAmount()));
|
||||
fluidTank.drain(((IFluidHandler)tileEntity).fill(orientation.getOpposite(), toDrain, true), true);
|
||||
|
||||
if(fluidTank.getFluid() == null || fluidTank.getFluid().amount <= 0)
|
||||
@@ -190,24 +226,23 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
|
||||
for(EnumFacing orientation : EnumFacing.VALUES)
|
||||
{
|
||||
Coord4D wrapper = Coord4D.get(this).offset(orientation);
|
||||
FluidStack fluid = MekanismUtils.getFluid(worldObj, wrapper, hasFilter());
|
||||
|
||||
if(MekanismUtils.isFluid(worldObj, wrapper))
|
||||
if(fluid != null && (activeType == null || fluid.getFluid() == activeType) && (fluidTank.getFluid() == null || fluidTank.getFluid().isFluidEqual(fluid)))
|
||||
{
|
||||
FluidStack fluid = MekanismUtils.getFluid(worldObj, wrapper, hasFilter());
|
||||
|
||||
if((activeType == null || fluid.getFluid() == activeType) && (fluidTank.getFluid() == null || fluidTank.getFluid().isFluidEqual(fluid)))
|
||||
if(take)
|
||||
{
|
||||
if(take)
|
||||
activeType = fluid.getFluid();
|
||||
recurringNodes.add(wrapper.clone());
|
||||
fluidTank.fill(fluid, true);
|
||||
|
||||
if(shouldTake(fluid, wrapper))
|
||||
{
|
||||
setEnergy(getEnergy() - usage.electricPumpUsage);
|
||||
activeType = fluid.getFluid();
|
||||
recurringNodes.add(wrapper.clone());
|
||||
fluidTank.fill(MekanismUtils.getFluid(worldObj, wrapper, hasFilter()), true);
|
||||
worldObj.setBlockToAir(wrapper);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,22 +250,22 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
|
||||
//and then add the adjacent block to the recurring list
|
||||
for(Coord4D wrapper : tempPumpList)
|
||||
{
|
||||
if(MekanismUtils.isFluid(worldObj, wrapper))
|
||||
FluidStack fluid = MekanismUtils.getFluid(worldObj, wrapper, hasFilter());
|
||||
|
||||
if(fluid != null && (activeType == null || fluid.getFluid() == activeType) && (fluidTank.getFluid() == null || fluidTank.getFluid().isFluidEqual(fluid)))
|
||||
{
|
||||
FluidStack fluid = MekanismUtils.getFluid(worldObj, wrapper, hasFilter());
|
||||
|
||||
if((activeType == null || fluid.getFluid() == activeType) && (fluidTank.getFluid() == null || fluidTank.getFluid().isFluidEqual(fluid)))
|
||||
if(take)
|
||||
{
|
||||
if(take)
|
||||
activeType = fluid.getFluid();
|
||||
fluidTank.fill(fluid, true);
|
||||
|
||||
if(shouldTake(fluid, wrapper))
|
||||
{
|
||||
setEnergy(getEnergy() - usage.electricPumpUsage);
|
||||
activeType = fluid.getFluid();
|
||||
fluidTank.fill(MekanismUtils.getFluid(worldObj, wrapper, hasFilter()), true);
|
||||
worldObj.setBlockToAir(wrapper);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//Add all the blocks surrounding this recurring node to the recurring node list
|
||||
@@ -238,25 +273,25 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
|
||||
{
|
||||
Coord4D side = wrapper.offset(orientation);
|
||||
|
||||
if(Coord4D.get(this).distanceTo(side) <= 80)
|
||||
if(Coord4D.get(this).distanceTo(side) <= general.maxPumpRange)
|
||||
{
|
||||
if(MekanismUtils.isFluid(worldObj, side))
|
||||
fluid = MekanismUtils.getFluid(worldObj, side, hasFilter());
|
||||
|
||||
if(fluid != null && (activeType == null || fluid.getFluid() == activeType) && (fluidTank.getFluid() == null || fluidTank.getFluid().isFluidEqual(fluid)))
|
||||
{
|
||||
FluidStack fluid = MekanismUtils.getFluid(worldObj, side, hasFilter());
|
||||
|
||||
if((activeType == null || fluid.getFluid() == activeType) && (fluidTank.getFluid() == null || fluidTank.getFluid().isFluidEqual(fluid)))
|
||||
if(take)
|
||||
{
|
||||
if(take)
|
||||
activeType = fluid.getFluid();
|
||||
recurringNodes.add(side);
|
||||
fluidTank.fill(fluid, true);
|
||||
|
||||
if(shouldTake(fluid, side))
|
||||
{
|
||||
setEnergy(getEnergy() - usage.electricPumpUsage);
|
||||
activeType = fluid.getFluid();
|
||||
recurringNodes.add(side);
|
||||
fluidTank.fill(MekanismUtils.getFluid(worldObj, side, hasFilter()), true);
|
||||
worldObj.setBlockToAir(side);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -272,6 +307,16 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
|
||||
activeType = null;
|
||||
recurringNodes.clear();
|
||||
}
|
||||
|
||||
private boolean shouldTake(FluidStack fluid, Coord4D coord)
|
||||
{
|
||||
if(fluid.getFluid() == FluidRegistry.WATER)
|
||||
{
|
||||
return general.pumpWaterSources;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacketData(ByteBuf dataStream)
|
||||
@@ -316,6 +361,9 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
|
||||
{
|
||||
super.writeToNBT(nbtTags);
|
||||
|
||||
nbtTags.setInteger("operatingTicks", operatingTicks);
|
||||
nbtTags.setBoolean("suckedLastOperation", suckedLastOperation);
|
||||
|
||||
if(activeType != null)
|
||||
{
|
||||
nbtTags.setString("activeType", FluidRegistry.getFluidName(activeType));
|
||||
@@ -348,6 +396,9 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
|
||||
{
|
||||
super.readFromNBT(nbtTags);
|
||||
|
||||
operatingTicks = nbtTags.getInteger("operatingTicks");
|
||||
suckedLastOperation = nbtTags.getBoolean("suckedLastOperation");
|
||||
|
||||
if(nbtTags.hasKey("activeType"))
|
||||
{
|
||||
activeType = FluidRegistry.getFluid(nbtTags.getString("activeType"));
|
||||
@@ -572,4 +623,21 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
|
||||
throw new NoSuchMethodException();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recalculateUpgradables(Upgrade upgrade)
|
||||
{
|
||||
super.recalculateUpgradables(upgrade);
|
||||
|
||||
switch(upgrade)
|
||||
{
|
||||
case SPEED:
|
||||
ticksRequired = MekanismUtils.getTicks(this, BASE_TICKS_REQUIRED);
|
||||
case ENERGY:
|
||||
energyPerTick = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_PER_TICK);
|
||||
maxEnergy = MekanismUtils.getMaxEnergy(this, BASE_MAX_ENERGY);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,7 @@ public class TileEntityEliteFactory extends TileEntityFactory
|
||||
configComponent.fillConfig(TransmissionType.GAS, 1);
|
||||
configComponent.setCanEject(TransmissionType.GAS, false);
|
||||
|
||||
configComponent.setInputEnergyConfig();
|
||||
configComponent.setInputConfig(TransmissionType.ENERGY);
|
||||
|
||||
upgradeComponent = new TileComponentUpgrade(this, 0);
|
||||
ejectorComponent = new TileComponentEjector(this);
|
||||
|
||||
@@ -1,15 +1,27 @@
|
||||
package mekanism.common.tile;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.Range4D;
|
||||
import mekanism.api.transmitters.TransmissionType;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.SideData;
|
||||
import mekanism.common.Tier.EnergyCubeTier;
|
||||
import mekanism.common.base.IEjector;
|
||||
import mekanism.common.base.IRedstoneControl;
|
||||
import mekanism.common.base.ISideConfiguration;
|
||||
import mekanism.common.integration.IComputerIntegration;
|
||||
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
import mekanism.common.tile.component.TileComponentConfig;
|
||||
import mekanism.common.tile.component.TileComponentEjector;
|
||||
import mekanism.common.util.CableUtils;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
import mekanism.common.util.LangUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -18,10 +30,7 @@ import net.minecraft.util.EnumFacing.Axis;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
|
||||
public class TileEntityEnergyCube extends TileEntityElectricBlock implements IComputerIntegration, IRedstoneControl
|
||||
public class TileEntityEnergyCube extends TileEntityElectricBlock implements IComputerIntegration, IRedstoneControl, ISideConfiguration
|
||||
{
|
||||
/** This Energy Cube's tier. */
|
||||
public EnergyCubeTier tier = EnergyCubeTier.BASIC;
|
||||
@@ -33,6 +42,9 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements ICo
|
||||
public RedstoneControl controlType;
|
||||
|
||||
public int prevScale;
|
||||
|
||||
public TileComponentEjector ejectorComponent;
|
||||
public TileComponentConfig configComponent;
|
||||
|
||||
/**
|
||||
* A block used to store and transfer electricity.
|
||||
@@ -40,9 +52,22 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements ICo
|
||||
public TileEntityEnergyCube()
|
||||
{
|
||||
super("EnergyCube", 0);
|
||||
|
||||
configComponent = new TileComponentConfig(this, TransmissionType.ITEM, TransmissionType.ENERGY);
|
||||
|
||||
configComponent.addOutput(TransmissionType.ITEM, new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY));
|
||||
configComponent.addOutput(TransmissionType.ITEM, new SideData("Charge", EnumColor.DARK_BLUE, new int[] {0}));
|
||||
configComponent.addOutput(TransmissionType.ITEM, new SideData("Discharge", EnumColor.DARK_RED, new int[] {1}));
|
||||
|
||||
configComponent.setConfig(TransmissionType.ITEM, new byte[] {0, 0, 0, 0, 2, 1});
|
||||
configComponent.setCanEject(TransmissionType.ITEM, false);
|
||||
configComponent.setIOConfig(TransmissionType.ENERGY);
|
||||
configComponent.setEjecting(TransmissionType.ENERGY, true);
|
||||
|
||||
inventory = new ItemStack[2];
|
||||
controlType = RedstoneControl.DISABLED;
|
||||
|
||||
ejectorComponent = new TileComponentEjector(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -55,7 +80,7 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements ICo
|
||||
ChargeUtils.charge(0, this);
|
||||
ChargeUtils.discharge(1, this);
|
||||
|
||||
if(MekanismUtils.canFunction(this))
|
||||
if(MekanismUtils.canFunction(this) && configComponent.isEjecting(TransmissionType.ENERGY))
|
||||
{
|
||||
CableUtils.emit(this);
|
||||
}
|
||||
@@ -101,16 +126,13 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements ICo
|
||||
@Override
|
||||
public EnumSet<EnumFacing> getConsumingSides()
|
||||
{
|
||||
EnumSet set = EnumSet.allOf(EnumFacing.class);
|
||||
set.removeAll(getOutputtingSides());
|
||||
|
||||
return set;
|
||||
return configComponent.getSidesForData(TransmissionType.ENERGY, facing, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<EnumFacing> getOutputtingSides()
|
||||
{
|
||||
return EnumSet.of(facing);
|
||||
return configComponent.getSidesForData(TransmissionType.ENERGY, facing, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -128,7 +150,7 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements ICo
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side)
|
||||
{
|
||||
return side.getAxis() == Axis.Y ? new int[] {0} : new int[] {1};
|
||||
return configComponent.getOutput(TransmissionType.ITEM, side, facing).availableSlots;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -187,11 +209,11 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements ICo
|
||||
@Override
|
||||
public ArrayList getNetworkedData(ArrayList<Object> data)
|
||||
{
|
||||
data.add(tier);
|
||||
data.add(tier.ordinal());
|
||||
|
||||
super.getNetworkedData(data);
|
||||
|
||||
data.add(controlType);
|
||||
data.add(controlType.ordinal());
|
||||
|
||||
return data;
|
||||
}
|
||||
@@ -256,4 +278,22 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements ICo
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEjector getEjector()
|
||||
{
|
||||
return ejectorComponent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileComponentConfig getConfig()
|
||||
{
|
||||
return configComponent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing getOrientation()
|
||||
{
|
||||
return facing;
|
||||
}
|
||||
}
|
||||
@@ -133,7 +133,7 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
||||
configComponent.fillConfig(TransmissionType.GAS, 1);
|
||||
configComponent.setCanEject(TransmissionType.GAS, false);
|
||||
|
||||
configComponent.setInputEnergyConfig();
|
||||
configComponent.setInputConfig(TransmissionType.ENERGY);
|
||||
|
||||
upgradeComponent = new TileComponentUpgrade(this, 0);
|
||||
ejectorComponent = new TileComponentEjector(this);
|
||||
|
||||
@@ -1,14 +1,29 @@
|
||||
package mekanism.common.tile;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.IConfigurable;
|
||||
import mekanism.api.MekanismConfig.general;
|
||||
import mekanism.api.MekanismConfig.usage;
|
||||
import mekanism.common.Upgrade;
|
||||
import mekanism.common.base.ISustainedTank;
|
||||
import mekanism.common.base.IUpgradeTile;
|
||||
import mekanism.common.block.states.BlockStateMachine;
|
||||
import mekanism.common.block.states.BlockStateMachine.MachineType;
|
||||
import mekanism.common.integration.IComputerIntegration;
|
||||
import mekanism.common.util.*;
|
||||
import mekanism.common.tile.component.TileComponentUpgrade;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import mekanism.common.util.FluidContainerUtils;
|
||||
import mekanism.common.util.LangUtils;
|
||||
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;
|
||||
@@ -16,15 +31,17 @@ import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraftforge.common.util.Constants.NBT;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.fluids.*;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidContainerItem;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import net.minecraftforge.fml.common.network.ByteBufUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implements IComputerIntegration, IConfigurable, IFluidHandler, ISustainedTank
|
||||
public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implements IComputerIntegration, IConfigurable, IFluidHandler, ISustainedTank, IUpgradeTile
|
||||
{
|
||||
public Set<Coord4D> activeNodes = new HashSet<Coord4D>();
|
||||
public Set<Coord4D> usedNodes = new HashSet<Coord4D>();
|
||||
@@ -33,12 +50,26 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen
|
||||
|
||||
public FluidTank fluidTank = new FluidTank(10000);
|
||||
|
||||
/** How much energy this machine consumes per-tick. */
|
||||
public double BASE_ENERGY_PER_TICK = usage.fluidicPlenisherUsage;
|
||||
|
||||
public double energyPerTick = BASE_ENERGY_PER_TICK;
|
||||
|
||||
/** How many ticks it takes to run an operation. */
|
||||
public int BASE_TICKS_REQUIRED = 20;
|
||||
|
||||
public int ticksRequired = BASE_TICKS_REQUIRED;
|
||||
|
||||
/** How many ticks this machine has been operating for. */
|
||||
public int operatingTicks;
|
||||
|
||||
private static EnumSet<EnumFacing> dirs = EnumSet.complementOf(EnumSet.of(EnumFacing.UP));
|
||||
private static int MAX_NODES = 4000;
|
||||
|
||||
public TileComponentUpgrade upgradeComponent = new TileComponentUpgrade(this, 3);
|
||||
|
||||
public TileEntityFluidicPlenisher()
|
||||
{
|
||||
super("FluidicPlenisher", BlockStateMachine.MachineType.FLUIDIC_PLENISHER.baseEnergy);
|
||||
super("FluidicPlenisher", MachineType.FLUIDIC_PLENISHER.baseEnergy);
|
||||
inventory = new ItemStack[3];
|
||||
}
|
||||
|
||||
@@ -121,10 +152,18 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen
|
||||
}
|
||||
}
|
||||
|
||||
if(getEnergy() >= usage.fluidicPlenisherUsage && worldObj.getWorldTime() % 10 == 0 && fluidTank.getFluidAmount() >= FluidContainerRegistry.BUCKET_VOLUME)
|
||||
if(MekanismUtils.canFunction(this) && getEnergy() >= energyPerTick && fluidTank.getFluid().getFluid().canBePlacedInWorld())
|
||||
{
|
||||
if(fluidTank.getFluid().getFluid().canBePlacedInWorld())
|
||||
if(!finishedCalc)
|
||||
{
|
||||
setEnergy(getEnergy() - energyPerTick);
|
||||
}
|
||||
|
||||
if((operatingTicks + 1) < ticksRequired)
|
||||
{
|
||||
operatingTicks++;
|
||||
}
|
||||
else {
|
||||
if(!finishedCalc)
|
||||
{
|
||||
doPlenish();
|
||||
@@ -132,17 +171,19 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen
|
||||
else {
|
||||
Coord4D below = Coord4D.get(this).offset(EnumFacing.DOWN);
|
||||
|
||||
if(canReplace(below, false, false) && getEnergy() >= usage.fluidicPlenisherUsage && fluidTank.getFluidAmount() >= FluidContainerRegistry.BUCKET_VOLUME)
|
||||
if(canReplace(below, false, false) && fluidTank.getFluidAmount() >= FluidContainerRegistry.BUCKET_VOLUME)
|
||||
{
|
||||
if(fluidTank.getFluid().getFluid().canBePlacedInWorld())
|
||||
{
|
||||
worldObj.setBlockState(below, MekanismUtils.getFlowingBlock(fluidTank.getFluid().getFluid()).getDefaultState(), 3);
|
||||
|
||||
setEnergy(getEnergy() - usage.fluidicPlenisherUsage);
|
||||
setEnergy(getEnergy() - energyPerTick);
|
||||
fluidTank.drain(FluidContainerRegistry.BUCKET_VOLUME, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
operatingTicks = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -150,7 +191,7 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen
|
||||
|
||||
private void doPlenish()
|
||||
{
|
||||
if(usedNodes.size() >= MAX_NODES)
|
||||
if(usedNodes.size() >= general.maxPlenisherNodes)
|
||||
{
|
||||
finishedCalc = true;
|
||||
return;
|
||||
@@ -186,9 +227,7 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen
|
||||
{
|
||||
worldObj.setBlockState(coord, MekanismUtils.getFlowingBlock(fluidTank.getFluid().getFluid()).getDefaultState(), 3);
|
||||
|
||||
setEnergy(getEnergy() - usage.fluidicPlenisherUsage);
|
||||
fluidTank.drain(FluidContainerRegistry.BUCKET_VOLUME, true);
|
||||
|
||||
}
|
||||
|
||||
for(EnumFacing dir : dirs)
|
||||
@@ -216,11 +255,6 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen
|
||||
}
|
||||
}
|
||||
|
||||
public int getActiveY()
|
||||
{
|
||||
return getPos().down().getY();
|
||||
}
|
||||
|
||||
public boolean canReplace(Coord4D coord, boolean checkNodes, boolean isPathfinding)
|
||||
{
|
||||
if(checkNodes && usedNodes.contains(coord))
|
||||
@@ -284,6 +318,7 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen
|
||||
{
|
||||
super.writeToNBT(nbtTags);
|
||||
|
||||
nbtTags.setInteger("operatingTicks", operatingTicks);
|
||||
nbtTags.setBoolean("finishedCalc", finishedCalc);
|
||||
|
||||
if(fluidTank.getFluid() != null)
|
||||
@@ -323,6 +358,7 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen
|
||||
{
|
||||
super.readFromNBT(nbtTags);
|
||||
|
||||
operatingTicks = nbtTags.getInteger("operatingTicks");
|
||||
finishedCalc = nbtTags.getBoolean("finishedCalc");
|
||||
|
||||
if(nbtTags.hasKey("fluidTank"))
|
||||
@@ -336,7 +372,7 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen
|
||||
|
||||
for(int i = 0; i < tagList.tagCount(); i++)
|
||||
{
|
||||
activeNodes.add(Coord4D.read((NBTTagCompound)tagList.getCompoundTagAt(i)));
|
||||
activeNodes.add(Coord4D.read(tagList.getCompoundTagAt(i)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -346,7 +382,7 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen
|
||||
|
||||
for(int i = 0; i < tagList.tagCount(); i++)
|
||||
{
|
||||
usedNodes.add(Coord4D.read((NBTTagCompound)tagList.getCompoundTagAt(i)));
|
||||
usedNodes.add(Coord4D.read(tagList.getCompoundTagAt(i)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -523,4 +559,27 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen
|
||||
throw new NoSuchMethodException();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileComponentUpgrade getComponent()
|
||||
{
|
||||
return upgradeComponent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recalculateUpgradables(Upgrade upgrade)
|
||||
{
|
||||
super.recalculateUpgradables(upgrade);
|
||||
|
||||
switch(upgrade)
|
||||
{
|
||||
case SPEED:
|
||||
ticksRequired = MekanismUtils.getTicks(this, BASE_TICKS_REQUIRED);
|
||||
case ENERGY:
|
||||
energyPerTick = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_PER_TICK);
|
||||
maxEnergy = MekanismUtils.getMaxEnergy(this, BASE_MAX_ENERGY);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,38 @@
|
||||
package mekanism.common.tile;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.gas.*;
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.gas.Gas;
|
||||
import mekanism.api.gas.GasRegistry;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.api.gas.GasTank;
|
||||
import mekanism.api.gas.GasTransmission;
|
||||
import mekanism.api.gas.IGasHandler;
|
||||
import mekanism.api.gas.IGasItem;
|
||||
import mekanism.api.gas.ITubeConnection;
|
||||
import mekanism.api.transmitters.TransmissionType;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.SideData;
|
||||
import mekanism.common.base.IEjector;
|
||||
import mekanism.common.base.IRedstoneControl;
|
||||
import mekanism.common.base.ISideConfiguration;
|
||||
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
import mekanism.common.tile.component.TileComponentConfig;
|
||||
import mekanism.common.tile.component.TileComponentEjector;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class TileEntityGasTank extends TileEntityContainerBlock implements IGasHandler, ITubeConnection, IRedstoneControl
|
||||
public class TileEntityGasTank extends TileEntityContainerBlock implements IGasHandler, ITubeConnection, IRedstoneControl, ISideConfiguration
|
||||
{
|
||||
public enum GasMode
|
||||
{
|
||||
@@ -40,63 +55,74 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH
|
||||
|
||||
/** This machine's current RedstoneControl type. */
|
||||
public RedstoneControl controlType;
|
||||
|
||||
public TileComponentEjector ejectorComponent;
|
||||
public TileComponentConfig configComponent;
|
||||
|
||||
public TileEntityGasTank()
|
||||
{
|
||||
super("GasTank");
|
||||
|
||||
configComponent = new TileComponentConfig(this, TransmissionType.ITEM, TransmissionType.GAS);
|
||||
|
||||
configComponent.addOutput(TransmissionType.ITEM, new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY));
|
||||
configComponent.addOutput(TransmissionType.ITEM, new SideData("Fill", EnumColor.DARK_BLUE, new int[] {0}));
|
||||
configComponent.addOutput(TransmissionType.ITEM, new SideData("Empty", EnumColor.DARK_RED, new int[] {1}));
|
||||
|
||||
configComponent.setConfig(TransmissionType.ITEM, new byte[] {2, 1, 0, 0, 0, 0});
|
||||
configComponent.setCanEject(TransmissionType.ITEM, false);
|
||||
configComponent.setIOConfig(TransmissionType.GAS);
|
||||
configComponent.setEjecting(TransmissionType.GAS, true);
|
||||
|
||||
inventory = new ItemStack[2];
|
||||
dumping = GasMode.IDLE;
|
||||
controlType = RedstoneControl.DISABLED;
|
||||
|
||||
ejectorComponent = new TileComponentEjector(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
if(inventory[0] != null && gasTank.getGas() != null)
|
||||
{
|
||||
gasTank.draw(GasTransmission.addGas(inventory[0], gasTank.getGas()), true);
|
||||
}
|
||||
|
||||
if(inventory[1] != null && (gasTank.getGas() == null || gasTank.getGas().amount < gasTank.getMaxGas()))
|
||||
{
|
||||
gasTank.receive(GasTransmission.removeGas(inventory[1], gasTank.getGasType(), gasTank.getNeeded()), true);
|
||||
}
|
||||
|
||||
if(!worldObj.isRemote && gasTank.getGas() != null && MekanismUtils.canFunction(this) && dumping != GasMode.DUMPING)
|
||||
{
|
||||
GasStack toSend = new GasStack(gasTank.getGas().getGas(), Math.min(gasTank.getStored(), output));
|
||||
|
||||
TileEntity tileEntity = Coord4D.get(this).offset(facing).getTileEntity(worldObj);
|
||||
|
||||
if(tileEntity instanceof IGasHandler)
|
||||
{
|
||||
if(((IGasHandler)tileEntity).canReceiveGas(facing.getOpposite(), gasTank.getGas().getGas()))
|
||||
{
|
||||
gasTank.draw(((IGasHandler)tileEntity).receiveGas(facing.getOpposite(), toSend, true), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!worldObj.isRemote && dumping == GasMode.DUMPING)
|
||||
{
|
||||
gasTank.draw(8, true);
|
||||
}
|
||||
|
||||
if(!worldObj.isRemote && dumping == GasMode.DUMPING_EXCESS && gasTank.getNeeded() < output)
|
||||
{
|
||||
gasTank.draw(output-gasTank.getNeeded(), true);
|
||||
}
|
||||
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
if(inventory[0] != null && gasTank.getGas() != null)
|
||||
{
|
||||
gasTank.draw(GasTransmission.addGas(inventory[0], gasTank.getGas()), true);
|
||||
}
|
||||
|
||||
if(inventory[1] != null && (gasTank.getGas() == null || gasTank.getGas().amount < gasTank.getMaxGas()))
|
||||
{
|
||||
gasTank.receive(GasTransmission.removeGas(inventory[1], gasTank.getGasType(), gasTank.getNeeded()), true);
|
||||
}
|
||||
|
||||
if(gasTank.getGas() != null && MekanismUtils.canFunction(this) && dumping != GasMode.DUMPING)
|
||||
{
|
||||
if(configComponent.isEjecting(TransmissionType.GAS))
|
||||
{
|
||||
GasStack toSend = new GasStack(gasTank.getGas().getGas(), Math.min(gasTank.getStored(), output));
|
||||
gasTank.draw(GasTransmission.emit(toSend, this, configComponent.getSidesForData(TransmissionType.GAS, facing, 2)), true);
|
||||
}
|
||||
}
|
||||
|
||||
if(dumping == GasMode.DUMPING)
|
||||
{
|
||||
gasTank.draw(8, true);
|
||||
}
|
||||
|
||||
if(dumping == GasMode.DUMPING_EXCESS && gasTank.getNeeded() < output)
|
||||
{
|
||||
gasTank.draw(output-gasTank.getNeeded(), true);
|
||||
}
|
||||
|
||||
int newGasAmount = gasTank.getStored();
|
||||
|
||||
if(newGasAmount != currentGasAmount)
|
||||
{
|
||||
markDirty();
|
||||
currentGasAmount = newGasAmount;
|
||||
MekanismUtils.saveChunk(this);
|
||||
}
|
||||
|
||||
currentGasAmount = newGasAmount;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +160,7 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side)
|
||||
{
|
||||
return side == EnumFacing.UP ? new int[]{0} : new int[]{1};
|
||||
return configComponent.getOutput(TransmissionType.ITEM, side, facing).availableSlots;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -170,8 +196,12 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH
|
||||
@Override
|
||||
public boolean canReceiveGas(EnumFacing side, Gas type)
|
||||
{
|
||||
return side != facing && gasTank.canReceive(type);
|
||||
if(configComponent.getSidesForData(TransmissionType.GAS, facing, 1).contains(side))
|
||||
{
|
||||
return gasTank.canReceive(type);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -189,7 +219,7 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH
|
||||
|
||||
for(EntityPlayer player : playersUsing)
|
||||
{
|
||||
Mekanism.packetHandler.sendTo(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), (EntityPlayerMP)player);
|
||||
Mekanism.packetHandler.sendTo(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList<Object>())), (EntityPlayerMP)player);
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -247,8 +277,8 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH
|
||||
data.add(false);
|
||||
}
|
||||
|
||||
data.add(dumping);
|
||||
data.add(controlType);
|
||||
data.add(dumping.ordinal());
|
||||
data.add(controlType.ordinal());
|
||||
|
||||
return data;
|
||||
}
|
||||
@@ -288,4 +318,22 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEjector getEjector()
|
||||
{
|
||||
return ejectorComponent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileComponentConfig getConfig()
|
||||
{
|
||||
return configComponent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing getOrientation()
|
||||
{
|
||||
return facing;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,10 @@
|
||||
package mekanism.common.tile;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.MekanismConfig.general;
|
||||
@@ -9,7 +13,12 @@ import mekanism.api.Range4D;
|
||||
import mekanism.api.infuse.InfuseObject;
|
||||
import mekanism.api.infuse.InfuseRegistry;
|
||||
import mekanism.api.transmitters.TransmissionType;
|
||||
import mekanism.common.*;
|
||||
import mekanism.common.InfuseStorage;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.MekanismItems;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.SideData;
|
||||
import mekanism.common.Upgrade;
|
||||
import mekanism.common.base.IEjector;
|
||||
import mekanism.common.base.IRedstoneControl;
|
||||
import mekanism.common.base.ISideConfiguration;
|
||||
@@ -31,9 +40,6 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
|
||||
public class TileEntityMetallurgicInfuser extends TileEntityNoisyElectricBlock implements IComputerIntegration, ISideConfiguration, IUpgradeTile, IRedstoneControl
|
||||
{
|
||||
/** The maxiumum amount of infuse this machine can store. */
|
||||
@@ -87,7 +93,7 @@ public class TileEntityMetallurgicInfuser extends TileEntityNoisyElectricBlock i
|
||||
configComponent.addOutput(TransmissionType.ITEM, new SideData("Energy", EnumColor.DARK_GREEN, new int[] {4}));
|
||||
|
||||
configComponent.setConfig(TransmissionType.ITEM, new byte[] {1, 0, 0, 4, 2, 3});
|
||||
configComponent.setInputEnergyConfig();
|
||||
configComponent.setInputConfig(TransmissionType.ENERGY);
|
||||
|
||||
inventory = new ItemStack[5];
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ public class TileEntityPRC extends TileEntityBasicMachine<PressurizedInput, Pres
|
||||
configComponent.addOutput(TransmissionType.GAS, new SideData("Output", EnumColor.DARK_BLUE, new int[] {2}));
|
||||
configComponent.setConfig(TransmissionType.GAS, new byte[] {0, 0, 0, 0, 1, 2});
|
||||
|
||||
configComponent.setInputEnergyConfig();
|
||||
configComponent.setInputConfig(TransmissionType.ENERGY);
|
||||
|
||||
inventory = new ItemStack[4];
|
||||
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package mekanism.common.tile;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.IConfigurable;
|
||||
import mekanism.api.MekanismConfig.general;
|
||||
import mekanism.api.Range4D;
|
||||
import mekanism.api.gas.IGasItem;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.base.IActiveState;
|
||||
import mekanism.common.base.IFluidContainerManager;
|
||||
@@ -22,7 +24,14 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.client.model.obj.OBJModel;
|
||||
import net.minecraftforge.fluids.*;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidContainerItem;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import net.minecraftforge.fml.common.network.ByteBufUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -110,6 +119,7 @@ public class TileEntityPortableTank extends TileEntityContainerBlock implements
|
||||
|
||||
if(fluidTank.getFluidAmount() != prevAmount)
|
||||
{
|
||||
MekanismUtils.saveChunk(this);
|
||||
needsPacket = true;
|
||||
}
|
||||
|
||||
@@ -154,13 +164,13 @@ public class TileEntityPortableTank extends TileEntityContainerBlock implements
|
||||
{
|
||||
if(inventory[0].getItem() instanceof IFluidContainerItem)
|
||||
{
|
||||
if(editMode == ContainerEditMode.FILL)
|
||||
if(editMode == ContainerEditMode.FILL && fluidTank.getFluidAmount() > 0)
|
||||
{
|
||||
int prev = fluidTank.getFluidAmount();
|
||||
|
||||
fluidTank.drain(FluidContainerUtils.insertFluid(fluidTank, inventory[0]), true);
|
||||
|
||||
if(prev == fluidTank.getFluidAmount() || fluidTank.getFluidAmount() == 0)
|
||||
if(prev == fluidTank.getFluidAmount())
|
||||
{
|
||||
if(inventory[1] == null)
|
||||
{
|
||||
@@ -297,24 +307,34 @@ public class TileEntityPortableTank extends TileEntityContainerBlock implements
|
||||
@Override
|
||||
public boolean canExtractItem(int slotID, ItemStack itemstack, EnumFacing side)
|
||||
{
|
||||
if(slotID == 1)
|
||||
{
|
||||
return (itemstack.getItem() instanceof IGasItem && ((IGasItem)itemstack.getItem()).getGas(itemstack) == null);
|
||||
}
|
||||
else if(slotID == 0)
|
||||
{
|
||||
return (itemstack.getItem() instanceof IGasItem && ((IGasItem)itemstack.getItem()).getGas(itemstack) != null &&
|
||||
((IGasItem)itemstack.getItem()).getGas(itemstack).amount == ((IGasItem)itemstack.getItem()).getMaxGas(itemstack));
|
||||
}
|
||||
|
||||
return false;
|
||||
return slotID == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slotID, ItemStack itemstack)
|
||||
{
|
||||
return slotID == 0 && FluidContainerRegistry.isContainer(itemstack);
|
||||
if(slotID == 0)
|
||||
{
|
||||
if(itemstack.getItem() instanceof IFluidContainerItem)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if(FluidContainerRegistry.isFilledContainer(itemstack))
|
||||
{
|
||||
FluidStack stack = FluidContainerRegistry.getFluidForFilledItem(itemstack);
|
||||
|
||||
if(fluidTank.getFluid() == null || fluidTank.getFluid().isFluidEqual(stack))
|
||||
{
|
||||
return editMode == ContainerEditMode.EMPTY || editMode == ContainerEditMode.BOTH;
|
||||
}
|
||||
}
|
||||
else if(FluidContainerRegistry.isEmptyContainer(itemstack))
|
||||
{
|
||||
return editMode == ContainerEditMode.FILL || editMode == ContainerEditMode.BOTH;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.util.Map;
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.transmitters.TransmissionType;
|
||||
import mekanism.common.SideData;
|
||||
import mekanism.common.SideData.EnergyState;
|
||||
import mekanism.common.SideData.IOState;
|
||||
import mekanism.common.base.ITileComponent;
|
||||
import mekanism.common.tile.TileEntityContainerBlock;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
@@ -93,22 +93,22 @@ public class TileComponentConfig implements ITileComponent
|
||||
setConfig(type, new byte[] {sideData, sideData, sideData, sideData, sideData, sideData});
|
||||
}
|
||||
|
||||
public void setIOEnergyConfig()
|
||||
public void setIOConfig(TransmissionType type)
|
||||
{
|
||||
addOutput(TransmissionType.ENERGY, new SideData("None", EnumColor.GREY, EnergyState.OFF));
|
||||
addOutput(TransmissionType.ENERGY, new SideData("Input", EnumColor.DARK_GREEN, EnergyState.INPUT));
|
||||
addOutput(TransmissionType.ENERGY, new SideData("Output", EnumColor.DARK_RED, EnergyState.OUTPUT));
|
||||
addOutput(type, new SideData("None", EnumColor.GREY, IOState.OFF));
|
||||
addOutput(type, new SideData("Input", EnumColor.DARK_GREEN, IOState.INPUT));
|
||||
addOutput(type, new SideData("Output", EnumColor.DARK_RED, IOState.OUTPUT));
|
||||
|
||||
setConfig(TransmissionType.ENERGY, new byte[] {1, 1, 2, 1, 1, 1});
|
||||
setConfig(type, new byte[] {1, 1, 2, 1, 1, 1});
|
||||
}
|
||||
|
||||
public void setInputEnergyConfig()
|
||||
public void setInputConfig(TransmissionType type)
|
||||
{
|
||||
addOutput(TransmissionType.ENERGY, new SideData("None", EnumColor.GREY, EnergyState.OFF));
|
||||
addOutput(TransmissionType.ENERGY, new SideData("Input", EnumColor.DARK_GREEN, EnergyState.INPUT));
|
||||
addOutput(type, new SideData("None", EnumColor.GREY, IOState.OFF));
|
||||
addOutput(type, new SideData("Input", EnumColor.DARK_GREEN, IOState.INPUT));
|
||||
|
||||
setConfig(TransmissionType.ENERGY, new byte[] {1, 1, 1, 1, 1, 1});
|
||||
setCanEject(TransmissionType.ENERGY, false);
|
||||
fillConfig(type, 1);
|
||||
setCanEject(type, false);
|
||||
}
|
||||
|
||||
public void setConfig(TransmissionType type, byte[] config)
|
||||
@@ -156,29 +156,10 @@ public class TileComponentConfig implements ITileComponent
|
||||
{
|
||||
for(TransmissionType type : transmissions)
|
||||
{
|
||||
try {//TODO remove soon
|
||||
if(nbtTags.getByteArray("config" + type).length > 0)
|
||||
{
|
||||
sideConfigs.put(type.ordinal(), nbtTags.getByteArray("config" + type));
|
||||
ejecting.put(type.ordinal(), nbtTags.getBoolean("ejecting" + type));
|
||||
}
|
||||
} catch(Exception e) {
|
||||
try {
|
||||
byte[] bytes = new byte[6];
|
||||
|
||||
for(int i = 0; i < 6; i++)
|
||||
{
|
||||
bytes[i] = nbtTags.getByte("config"+i);
|
||||
|
||||
if(bytes[i] > 0)
|
||||
{
|
||||
bytes[i]--;
|
||||
}
|
||||
}
|
||||
|
||||
sideConfigs.put(TransmissionType.ITEM.ordinal(), bytes);
|
||||
ejecting.put(TransmissionType.ITEM.ordinal(), nbtTags.getBoolean("ejecting"));
|
||||
} catch(Exception e1) {}
|
||||
if(nbtTags.getByteArray("config" + type.ordinal()).length > 0)
|
||||
{
|
||||
sideConfigs.put(type.ordinal(), nbtTags.getByteArray("config" + type.ordinal()));
|
||||
ejecting.put(type.ordinal(), nbtTags.getBoolean("ejecting" + type.ordinal()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ public class TileComponentEjector implements ITileComponent, IEjector
|
||||
if(tank.getStored() > 0)
|
||||
{
|
||||
GasStack toEmit = tank.getGas().copy().withAmount(Math.min(GAS_OUTPUT, tank.getStored()));
|
||||
int emit = GasTransmission.emit(outputSides, toEmit, tileEntity);
|
||||
int emit = GasTransmission.emit(toEmit, tileEntity, outputSides);
|
||||
tank.draw(emit, true);
|
||||
}
|
||||
}
|
||||
@@ -145,7 +145,6 @@ public class TileComponentEjector implements ITileComponent, IEjector
|
||||
public List<EnumFacing> getOutputSides(TransmissionType type, SideData data)
|
||||
{
|
||||
List<EnumFacing> outputSides = new ArrayList<EnumFacing>();
|
||||
|
||||
ISideConfiguration configurable = (ISideConfiguration)tileEntity;
|
||||
|
||||
for(int i = 0; i < configurable.getConfig().getConfig(type).length; i++)
|
||||
|
||||
@@ -2,11 +2,12 @@ package mekanism.common.util;
|
||||
|
||||
import ic2.api.item.ElectricItem;
|
||||
import ic2.api.item.IElectricItem;
|
||||
import ic2.api.item.IElectricItemManager;
|
||||
import ic2.api.item.ISpecialElectricItem;
|
||||
import mekanism.api.MekanismConfig.general;
|
||||
import mekanism.api.energy.EnergizedItemManager;
|
||||
import mekanism.api.energy.IEnergizedItem;
|
||||
import mekanism.api.energy.IStrictEnergyStorage;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.tile.TileEntityContainerBlock;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@@ -130,6 +131,46 @@ public final class ChargeUtils
|
||||
*/
|
||||
public static boolean canBeOutputted(ItemStack itemstack, boolean chargeSlot)
|
||||
{
|
||||
return true; //this is too much of a hassle to manage
|
||||
if(itemstack.getItem() instanceof IEnergizedItem)
|
||||
{
|
||||
IEnergizedItem energized = (IEnergizedItem)itemstack.getItem();
|
||||
|
||||
if(chargeSlot)
|
||||
{
|
||||
return energized.getEnergy(itemstack) == energized.getMaxEnergy(itemstack);
|
||||
}
|
||||
else {
|
||||
return energized.getEnergy(itemstack) == 0;
|
||||
}
|
||||
}
|
||||
else if(itemstack.getItem() instanceof IEnergyContainerItem)
|
||||
{
|
||||
IEnergyContainerItem energyContainer = (IEnergyContainerItem)itemstack.getItem();
|
||||
|
||||
if(chargeSlot)
|
||||
{
|
||||
return energyContainer.receiveEnergy(itemstack, 1, true) > 0;
|
||||
}
|
||||
else {
|
||||
return energyContainer.extractEnergy(itemstack, 1, true) > 0;
|
||||
}
|
||||
}
|
||||
else if(itemstack.getItem() instanceof ISpecialElectricItem)
|
||||
{
|
||||
IElectricItemManager manager = ((ISpecialElectricItem)itemstack.getItem()).getManager(itemstack);
|
||||
|
||||
if(manager != null)
|
||||
{
|
||||
if(chargeSlot)
|
||||
{
|
||||
return manager.charge(itemstack, 1, 3, true, true) > 0;
|
||||
}
|
||||
else {
|
||||
return manager.discharge(itemstack, 1, 3, true, true, true) > 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -3,17 +3,20 @@ package mekanism.generators.client.render;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.client.render.MekanismRenderer;
|
||||
import mekanism.client.render.MekanismRenderer.DisplayInteger;
|
||||
import mekanism.client.render.MekanismRenderer.Model3D;
|
||||
import mekanism.client.render.tileentity.RenderDynamicTank.RenderData;
|
||||
import mekanism.common.content.tank.TankUpdateProtocol;
|
||||
import mekanism.generators.common.tile.turbine.TileEntityTurbineCasing;
|
||||
import mekanism.generators.common.tile.turbine.TileEntityTurbineRotor;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
|
||||
@@ -33,58 +36,79 @@ public class RenderIndustrialTurbine extends TileEntitySpecialRenderer
|
||||
|
||||
public void renderAModelAt(TileEntityTurbineCasing tileEntity, double x, double y, double z, float partialTick)
|
||||
{
|
||||
if(tileEntity.clientHasStructure && tileEntity.isRendering && tileEntity.structure != null && tileEntity.structure.fluidStored != null && tileEntity.structure.fluidStored.amount != 0)
|
||||
if(tileEntity.clientHasStructure && tileEntity.isRendering && tileEntity.structure != null)
|
||||
{
|
||||
RenderData data = new RenderData();
|
||||
|
||||
data.location = tileEntity.structure.renderLocation;
|
||||
data.height = tileEntity.structure.lowerVolume/(tileEntity.structure.volLength*tileEntity.structure.volWidth);
|
||||
data.length = tileEntity.structure.volLength;
|
||||
data.width = tileEntity.structure.volWidth;
|
||||
RenderTurbineRotor.internalRender = true;
|
||||
Coord4D coord = tileEntity.structure.complex;
|
||||
|
||||
bindTexture(MekanismRenderer.getBlocksTexture());
|
||||
|
||||
if(data.location != null && data.height >= 3 && tileEntity.structure.fluidStored.getFluid() != null)
|
||||
while(true)
|
||||
{
|
||||
push();
|
||||
|
||||
GL11.glTranslated(getX(data.location.xCoord), getY(data.location.yCoord), getZ(data.location.zCoord));
|
||||
|
||||
MekanismRenderer.glowOn(tileEntity.structure.fluidStored.getFluid().getLuminosity());
|
||||
MekanismRenderer.colorFluid(tileEntity.structure.fluidStored.getFluid());
|
||||
|
||||
DisplayInteger[] displayList = getListAndRender(data, tileEntity.getWorldObj());
|
||||
|
||||
GL11.glColor4f(1F, 1F, 1F, Math.min(1, ((float)tileEntity.structure.fluidStored.amount / (float)tileEntity.structure.getFluidCapacity())+0.3F));
|
||||
displayList[getStages(data.height)-1].render();
|
||||
|
||||
MekanismRenderer.glowOff();
|
||||
MekanismRenderer.resetColor();
|
||||
|
||||
pop();
|
||||
coord = coord.getFromSide(ForgeDirection.DOWN);
|
||||
TileEntity tile = coord.getTileEntity(tileEntity.getWorldObj());
|
||||
|
||||
if(!(tile instanceof TileEntityTurbineRotor))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
TileEntityRendererDispatcher.instance.renderTileEntity(tile, partialTick);
|
||||
}
|
||||
|
||||
RenderTurbineRotor.internalRender = false;
|
||||
|
||||
if(tileEntity.structure.fluidStored != null && tileEntity.structure.fluidStored.amount != 0)
|
||||
{
|
||||
RenderData data = new RenderData();
|
||||
|
||||
data.location = tileEntity.structure.renderLocation;
|
||||
data.height = tileEntity.structure.lowerVolume/(tileEntity.structure.volLength*tileEntity.structure.volWidth);
|
||||
data.length = tileEntity.structure.volLength;
|
||||
data.width = tileEntity.structure.volWidth;
|
||||
|
||||
bindTexture(MekanismRenderer.getBlocksTexture());
|
||||
|
||||
if(data.location != null && data.height >= 1 && tileEntity.structure.fluidStored.getFluid() != null)
|
||||
{
|
||||
push();
|
||||
|
||||
GL11.glTranslated(getX(data.location.xCoord), getY(data.location.yCoord), getZ(data.location.zCoord));
|
||||
|
||||
MekanismRenderer.glowOn(tileEntity.structure.fluidStored.getFluid().getLuminosity());
|
||||
MekanismRenderer.colorFluid(tileEntity.structure.fluidStored.getFluid());
|
||||
|
||||
DisplayInteger[] displayList = getListAndRender(data, tileEntity.getWorldObj());
|
||||
|
||||
GL11.glColor4f(1F, 1F, 1F, Math.min(1, ((float)tileEntity.structure.fluidStored.amount / (float)tileEntity.structure.getFluidCapacity())+0.3F));
|
||||
displayList[getStages(data.height+1)-1].render();
|
||||
|
||||
MekanismRenderer.glowOff();
|
||||
MekanismRenderer.resetColor();
|
||||
|
||||
pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void pop()
|
||||
{
|
||||
GL11.glPopAttrib();
|
||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
private void push()
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
|
||||
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
|
||||
private int getStages(int height)
|
||||
{
|
||||
return (height-2)*(TankUpdateProtocol.FLUID_PER_TANK/10);
|
||||
return TankUpdateProtocol.FLUID_PER_TANK/10;
|
||||
}
|
||||
|
||||
private double getX(int x)
|
||||
@@ -129,7 +153,7 @@ public class RenderIndustrialTurbine extends TileEntitySpecialRenderer
|
||||
toReturn.minZ = 0 + .01;
|
||||
|
||||
toReturn.maxX = data.length - .01;
|
||||
toReturn.maxY = ((float)i/(float)stages)*(data.height-2) - .01;
|
||||
toReturn.maxY = ((float)i/(float)stages)*(data.height+1) - .01;
|
||||
toReturn.maxZ = data.width - .01;
|
||||
|
||||
MekanismRenderer.renderObject(toReturn);
|
||||
|
||||
@@ -17,6 +17,8 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderTurbineRotor extends TileEntitySpecialRenderer
|
||||
{
|
||||
public static boolean internalRender = false;
|
||||
|
||||
private ModelTurbine model = new ModelTurbine();
|
||||
|
||||
private static final float BASE_SPEED = 512F;
|
||||
@@ -29,6 +31,11 @@ public class RenderTurbineRotor extends TileEntitySpecialRenderer
|
||||
|
||||
private void renderAModelAt(TileEntityTurbineRotor tileEntity, double x, double y, double z, float partialTick)
|
||||
{
|
||||
if(tileEntity.multiblockUUID != null && !internalRender)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GL11.glPushMatrix();
|
||||
|
||||
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "Turbine.png"));
|
||||
|
||||
@@ -21,6 +21,7 @@ public class SynchronizedTurbineData extends SynchronizedData<SynchronizedTurbin
|
||||
public Coord4D complex;
|
||||
|
||||
public int lastSteamInput;
|
||||
public int newSteamInput;
|
||||
|
||||
public int clientDispersers;
|
||||
public int clientFlow;
|
||||
|
||||
+15
-2
@@ -63,6 +63,17 @@ public class TurbineUpdateProtocol extends UpdateProtocol<SynchronizedTurbineDat
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStructureDestroyed(SynchronizedTurbineData structure)
|
||||
{
|
||||
TileEntity tile = structure.complex.getTileEntity(pointer.getWorldObj());
|
||||
|
||||
if(tile instanceof TileEntityRotationalComplex)
|
||||
{
|
||||
((TileEntityRotationalComplex)tile).setMultiblock(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canForm(SynchronizedTurbineData structure)
|
||||
{
|
||||
@@ -207,8 +218,6 @@ public class TurbineUpdateProtocol extends UpdateProtocol<SynchronizedTurbineDat
|
||||
}
|
||||
|
||||
structure.lowerVolume = structure.volLength*structure.volWidth*turbineHeight;
|
||||
|
||||
((TileEntityRotationalComplex)complex.getTileEntity(pointer.getWorldObj())).setMultiblock(structure.inventoryID);
|
||||
structure.complex = complex;
|
||||
|
||||
return true;
|
||||
@@ -247,6 +256,8 @@ public class TurbineUpdateProtocol extends UpdateProtocol<SynchronizedTurbineDat
|
||||
{
|
||||
((TurbineCache)cache).fluid.amount += ((TurbineCache)merge).fluid.amount;
|
||||
}
|
||||
|
||||
((TurbineCache)cache).electricity += ((TurbineCache)merge).electricity;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -258,6 +269,8 @@ public class TurbineUpdateProtocol extends UpdateProtocol<SynchronizedTurbineDat
|
||||
}
|
||||
|
||||
structureFound.electricityStored = Math.min(structureFound.electricityStored, structureFound.getEnergyCapacity());
|
||||
|
||||
((TileEntityRotationalComplex)structureFound.complex.getTileEntity(pointer.getWorldObj())).setMultiblock(structureFound.inventoryID);
|
||||
}
|
||||
|
||||
public class CoilCounter
|
||||
|
||||
+3
-9
@@ -19,7 +19,7 @@ public class TileEntityRotationalComplex extends TileEntityBasicBlock
|
||||
{
|
||||
public static Map<String, Float> clientRotationMap = new HashMap<String, Float>();
|
||||
|
||||
public static final float ROTATION_THRESHOLD = 0.01F;
|
||||
public static final float ROTATION_THRESHOLD = 0.001F;
|
||||
|
||||
public String multiblockUUID;
|
||||
public float rotation;
|
||||
@@ -28,15 +28,9 @@ public class TileEntityRotationalComplex extends TileEntityBasicBlock
|
||||
public void onUpdate() {}
|
||||
|
||||
@Override
|
||||
public void onAdded()
|
||||
public boolean canUpdate()
|
||||
{
|
||||
super.onAdded();
|
||||
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
setMultiblock("asdf");
|
||||
setRotation(1F);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -65,8 +65,6 @@ public class TileEntityTurbineCasing extends TileEntityMultiblock<SynchronizedTu
|
||||
{
|
||||
if(structure != null)
|
||||
{
|
||||
structure.lastSteamInput = 0;
|
||||
|
||||
if(structure.fluidStored != null && structure.fluidStored.amount <= 0)
|
||||
{
|
||||
structure.fluidStored = null;
|
||||
@@ -75,20 +73,24 @@ public class TileEntityTurbineCasing extends TileEntityMultiblock<SynchronizedTu
|
||||
|
||||
if(isRendering)
|
||||
{
|
||||
structure.lastSteamInput = structure.newSteamInput;
|
||||
structure.newSteamInput = 0;
|
||||
|
||||
int stored = structure.fluidStored != null ? structure.fluidStored.amount : 0;
|
||||
double proportion = (double)stored/(double)structure.getFluidCapacity();
|
||||
double flowRate = 0;
|
||||
|
||||
if(stored > 0 && structure.electricityStored < structure.getEnergyCapacity())
|
||||
if(stored > 0 && getEnergy() < structure.getEnergyCapacity())
|
||||
{
|
||||
double energyMultiplier = ENERGY_PER_STEAM*Math.min(structure.blades, structure.coils*BLADE_TO_COIL_RATIO);
|
||||
double rate = structure.lowerVolume*(structure.getDispersers()*DISPERSER_GAS_FLOW)*proportion;
|
||||
double rate = structure.lowerVolume*(structure.getDispersers()*DISPERSER_GAS_FLOW);
|
||||
rate = Math.min(rate, structure.vents*VENT_GAS_FLOW);
|
||||
|
||||
double origRate = rate;
|
||||
|
||||
rate = Math.min(Math.min(stored, rate), structure.vents*VENT_GAS_FLOW);
|
||||
rate = Math.min(rate, (getMaxEnergy()-getEnergy())/energyMultiplier);
|
||||
rate = Math.min(Math.min(stored, rate), (getMaxEnergy()-getEnergy())/energyMultiplier)*proportion;
|
||||
|
||||
flowRate = proportion*(rate/origRate);
|
||||
flowRate = rate/origRate;
|
||||
setEnergy(getEnergy()+((int)rate)*energyMultiplier);
|
||||
|
||||
structure.fluidStored.amount -= rate;
|
||||
@@ -199,6 +201,11 @@ public class TileEntityTurbineCasing extends TileEntityMultiblock<SynchronizedTu
|
||||
else {
|
||||
data.add(0);
|
||||
}
|
||||
|
||||
if(isRendering)
|
||||
{
|
||||
structure.complex.write(data);
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
@@ -228,6 +235,11 @@ public class TileEntityTurbineCasing extends TileEntityMultiblock<SynchronizedTu
|
||||
else {
|
||||
structure.fluidStored = null;
|
||||
}
|
||||
|
||||
if(isRendering)
|
||||
{
|
||||
structure.complex = Coord4D.read(dataStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -363,7 +363,7 @@ public class TileEntityTurbineValve extends TileEntityTurbineCasing implements I
|
||||
|
||||
if(structure != null && doFill)
|
||||
{
|
||||
structure.lastSteamInput += filled;
|
||||
structure.newSteamInput += filled;
|
||||
}
|
||||
|
||||
return filled;
|
||||
|
||||
Reference in new issue
Block a user