mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-23 21:39:40 +00:00
Add a machine that slowly collects the ambient gas of vanilla dimensions.
It could do with a model I think, something like a bellows maybe?
This commit is contained in:
1 parent
fc8fab1987
commit
c7057114bc
5 files changed
+180
-1
No files matched your search
@@ -6,6 +6,7 @@ import mekanism.api.Coord4D;
|
||||
import mekanism.api.MekanismConfig.client;
|
||||
import mekanism.api.MekanismConfig.general;
|
||||
import mekanism.client.entity.EntityLaser;
|
||||
import mekanism.client.gui.GuiAmbientAccumulator;
|
||||
import mekanism.client.gui.GuiChemicalCrystallizer;
|
||||
import mekanism.client.gui.GuiChemicalDissolutionChamber;
|
||||
import mekanism.client.gui.GuiChemicalInfuser;
|
||||
@@ -107,6 +108,7 @@ import mekanism.common.item.ItemPortableTeleporter;
|
||||
import mekanism.common.item.ItemSeismicReader;
|
||||
import mekanism.common.tile.TileEntityAdvancedElectricMachine;
|
||||
import mekanism.common.tile.TileEntityAdvancedFactory;
|
||||
import mekanism.common.tile.TileEntityAmbientAccumulator;
|
||||
import mekanism.common.tile.TileEntityBin;
|
||||
import mekanism.common.tile.TileEntityChargepad;
|
||||
import mekanism.common.tile.TileEntityChemicalCrystallizer;
|
||||
@@ -162,6 +164,7 @@ import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@@ -299,6 +302,7 @@ public class ClientProxy extends CommonProxy
|
||||
ClientRegistry.registerTileEntity(TileEntityFluidicPlenisher.class, "FluidicPlenisher", new RenderFluidicPlenisher());
|
||||
ClientRegistry.registerTileEntity(TileEntityLaser.class, "Laser", new RenderLaser());
|
||||
ClientRegistry.registerTileEntity(TileEntityLaserAmplifier.class, "LaserAmplifier", new RenderLaserAmplifier());
|
||||
GameRegistry.registerTileEntity(TileEntityAmbientAccumulator.class, "AmbientAccumulator");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -462,6 +466,8 @@ public class ClientProxy extends CommonProxy
|
||||
return new GuiLaserAmplifier(player.inventory, (TileEntityLaserAmplifier)tileEntity);
|
||||
case 45:
|
||||
return new GuiEntangledBlock(player.inventory, (TileEntityEntangledBlock)tileEntity);
|
||||
case 46:
|
||||
return new GuiAmbientAccumulator(player, (TileEntityAmbientAccumulator)tileEntity);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package mekanism.client.gui;
|
||||
|
||||
import mekanism.api.gas.GasTank;
|
||||
import mekanism.client.gui.GuiGasGauge.IGasInfoHandler;
|
||||
import mekanism.client.gui.GuiGauge.Type;
|
||||
import mekanism.common.inventory.container.ContainerNull;
|
||||
import mekanism.common.tile.TileEntityAmbientAccumulator;
|
||||
import mekanism.common.tile.TileEntityContainerBlock;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.MekanismUtils.ResourceType;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class GuiAmbientAccumulator extends GuiMekanism
|
||||
{
|
||||
TileEntityAmbientAccumulator tileEntity;
|
||||
|
||||
public GuiAmbientAccumulator(EntityPlayer player, TileEntityAmbientAccumulator tile)
|
||||
{
|
||||
super(new ContainerNull(player, tile));
|
||||
tileEntity = tile;
|
||||
|
||||
guiElements.add(new GuiGasGauge(new IGasInfoHandler() {
|
||||
@Override
|
||||
public GasTank getTank()
|
||||
{
|
||||
return tileEntity.collectedGas;
|
||||
}
|
||||
}, Type.WIDE, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 26, 16));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
|
||||
{
|
||||
fontRendererObj.drawString(tileEntity.getInventoryName(), 45, 6, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040);
|
||||
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY)
|
||||
{
|
||||
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"));
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
int guiWidth = (width - xSize) / 2;
|
||||
int guiHeight = (height - ySize) / 2;
|
||||
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
|
||||
|
||||
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
@@ -43,6 +43,7 @@ import mekanism.common.inventory.container.ContainerTeleporter;
|
||||
import mekanism.common.inventory.container.ContainerUpgradeManagement;
|
||||
import mekanism.common.tile.TileEntityAdvancedElectricMachine;
|
||||
import mekanism.common.tile.TileEntityAdvancedFactory;
|
||||
import mekanism.common.tile.TileEntityAmbientAccumulator;
|
||||
import mekanism.common.tile.TileEntityBin;
|
||||
import mekanism.common.tile.TileEntityChanceMachine;
|
||||
import mekanism.common.tile.TileEntityChargepad;
|
||||
@@ -147,6 +148,7 @@ public class CommonProxy
|
||||
GameRegistry.registerTileEntity(TileEntityFluidicPlenisher.class, "FluidicPlenisher");
|
||||
GameRegistry.registerTileEntity(TileEntityLaser.class, "Laser");
|
||||
GameRegistry.registerTileEntity(TileEntityLaserAmplifier.class, "LaserAmplifier");
|
||||
GameRegistry.registerTileEntityWithAlternatives(TileEntityAmbientAccumulator.class, "AmbientAccumulator");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -419,6 +421,7 @@ public class CommonProxy
|
||||
return new ContainerUpgradeManagement(player.inventory, (IUpgradeTile)tileEntity);
|
||||
case 44:
|
||||
case 45:
|
||||
case 46:
|
||||
return new ContainerNull(player, (TileEntityContainerBlock)tileEntity);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import mekanism.common.network.PacketElectricChest.ElectricChestPacketType;
|
||||
import mekanism.common.network.PacketLogisticalSorterGui.LogisticalSorterGuiMessage;
|
||||
import mekanism.common.network.PacketLogisticalSorterGui.SorterGuiPacket;
|
||||
import mekanism.common.tile.TileEntityAdvancedFactory;
|
||||
import mekanism.common.tile.TileEntityAmbientAccumulator;
|
||||
import mekanism.common.tile.TileEntityBasicBlock;
|
||||
import mekanism.common.tile.TileEntityChargepad;
|
||||
import mekanism.common.tile.TileEntityChemicalCrystallizer;
|
||||
@@ -132,6 +133,7 @@ import dan200.computercraft.api.peripheral.IPeripheralProvider;
|
||||
* 1:13: Laser
|
||||
* 1:14: Laser Amplifier
|
||||
* 1:15: Entangled Block
|
||||
* 2:0: Ambient Accumulator
|
||||
* @author AidanBrady
|
||||
*
|
||||
*/
|
||||
@@ -1060,7 +1062,8 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer
|
||||
FLUIDIC_PLENISHER(MachineBlock.MACHINE_BLOCK_2, 12, "FluidicPlenisher", 42, 10000, TileEntityFluidicPlenisher.class, true, true, false),
|
||||
LASER(MachineBlock.MACHINE_BLOCK_2, 13, "Laser", -1, 100000, TileEntityLaser.class, true, true, false),
|
||||
LASER_AMPLIFIER(MachineBlock.MACHINE_BLOCK_2, 14, "LaserAmplifier", 44, 0, TileEntityLaserAmplifier.class, false, true, false),
|
||||
ENTANGLED_BLOCK(MachineBlock.MACHINE_BLOCK_2, 15, "EntangledBlock", 45, 0, TileEntityEntangledBlock.class, true, false, false);
|
||||
ENTANGLED_BLOCK(MachineBlock.MACHINE_BLOCK_2, 15, "EntangledBlock", 45, 0, TileEntityEntangledBlock.class, true, false, false),
|
||||
AMBIENT_ACCUMULATOR(MachineBlock.MACHINE_BLOCK_3, 0, "AmbientAccumulator", 46, 0, TileEntityAmbientAccumulator.class, true, false, false);
|
||||
|
||||
public MachineBlock typeBlock;
|
||||
public int meta;
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
package mekanism.common.tile;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import mekanism.api.gas.Gas;
|
||||
import mekanism.api.gas.GasRegistry;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.api.gas.GasTank;
|
||||
import mekanism.api.gas.IGasHandler;
|
||||
import mekanism.api.gas.ITubeConnection;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public class TileEntityAmbientAccumulator extends TileEntityContainerBlock implements IGasHandler, ITubeConnection
|
||||
{
|
||||
public GasTank collectedGas = new GasTank(1000);
|
||||
|
||||
public static Map<Integer, String> dimensionGases = new HashMap<Integer, String>();
|
||||
|
||||
public static Random gasRand = new Random();
|
||||
|
||||
static
|
||||
{
|
||||
dimensionGases.put(-1, "sulfurDioxideGas");
|
||||
dimensionGases.put(+0, "oxygen");
|
||||
dimensionGases.put(+1, "tritium");
|
||||
}
|
||||
|
||||
public TileEntityAmbientAccumulator()
|
||||
{
|
||||
super("AmbientAccumulator");
|
||||
inventory = new ItemStack[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
Gas gasToCollect = GasRegistry.getGas(dimensionGases.get(worldObj.provider.dimensionId));
|
||||
|
||||
if(gasToCollect != null && gasRand.nextDouble() < 0.05)
|
||||
{
|
||||
collectedGas.receive(new GasStack(gasToCollect, 1), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int receiveGas(ForgeDirection side, GasStack stack, boolean doTransfer)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GasStack drawGas(ForgeDirection side, int amount, boolean doTransfer)
|
||||
{
|
||||
return collectedGas.draw(amount, doTransfer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReceiveGas(ForgeDirection side, Gas type)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrawGas(ForgeDirection side, Gas type)
|
||||
{
|
||||
return type == collectedGas.getGasType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTubeConnect(ForgeDirection side)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList getNetworkedData(ArrayList data)
|
||||
{
|
||||
if(collectedGas.getGasType() != null)
|
||||
{
|
||||
data.add(collectedGas.getGasType().getID());
|
||||
data.add(collectedGas.getStored());
|
||||
} else
|
||||
{
|
||||
data.add(-1);
|
||||
data.add(0);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacketData(ByteBuf data)
|
||||
{
|
||||
int gasID = data.readInt();
|
||||
if(gasID < 0)
|
||||
{
|
||||
collectedGas.setGas(null);
|
||||
} else
|
||||
{
|
||||
collectedGas.setGas(new GasStack(gasID, data.readInt()));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user