mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-08-10 17:55:44 +00:00
storag
This commit is contained in:
parent
62ef455432
commit
7fdd48f29f
@ -29,3 +29,4 @@
|
||||
* Fixed AUTOCAL's file opening buttons not working on some systems, it will fall back to opening the folder instead
|
||||
* Fixed some recipes not using ore dict when they should
|
||||
* Fixed `anyBismoid` group not being a proper group, causing other mods' bismuth and arsenic to not be included
|
||||
* Fixed RoR gauge not using SI suffixes on values below 0
|
||||
@ -30,6 +30,9 @@ public interface ISlotMonitorProvider {
|
||||
/** Sets the slot contents, returns the number of items that couldn't be added */
|
||||
public long setupType(int index, ItemStack zeroStack, long amount);
|
||||
|
||||
/** Whether this container allows types to be set via the access terminal */
|
||||
public boolean allowTypeSetting();
|
||||
|
||||
/** Whether this storage unit is reachable by the access point */
|
||||
public boolean isAvailableToCache(StackCache cache);
|
||||
|
||||
|
||||
@ -90,6 +90,7 @@ public class StackCache {
|
||||
CacheSlot nullCache = this.cacheSlots.get(getNullIdentity());
|
||||
if(nullCache != null) { // quite ironic, isn't it?
|
||||
for(SlotMonitor monitor : nullCache.monitors) {
|
||||
if(!monitor.parent.allowTypeSetting()) continue;
|
||||
if(monitor.parent.getSlotAt(monitor.index) != null) continue;
|
||||
amount = monitor.parent.setupType(monitor.index, stack, amount);
|
||||
if(amount <= 0) break;
|
||||
|
||||
@ -1,7 +1,12 @@
|
||||
package com.hbm.blocks.network.pneumatic;
|
||||
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.tileentity.network.pneumatic.TileEntityPneumoStorageMono;
|
||||
|
||||
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@ -13,7 +18,16 @@ public class PneumoStorageMono extends BlockContainer {
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
return null;
|
||||
return new TileEntityPneumoStorageMono();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
|
||||
if(world.isRemote) return true;
|
||||
if(!player.isSneaking()) {
|
||||
FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -320,7 +320,7 @@ public class OreDictManager {
|
||||
public static final DictFrame ANY_CONCRETE = new DictFrame("Concrete"); //no any prefix means that any has to be appended with the any() or anys() getters, registering works with the any (i.e. no shape) setter
|
||||
public static final DictGroup ANY_TAR = new DictGroup("Tar", KEY_OIL_TAR, KEY_COAL_TAR, KEY_CRACK_TAR, KEY_WOOD_TAR);
|
||||
/** Any special post-RBMK gating material, namely bismuth and arsenic */
|
||||
public static final DictGroup ANY_BISMOID = new DictGroup("AnyBismoid");
|
||||
public static final DictGroup ANY_BISMOID = new DictGroup("AnyBismoid", BI, AS);
|
||||
public static final DictFrame ANY_ASH = new DictFrame("Ash");
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,52 @@
|
||||
package com.hbm.inventory.container;
|
||||
|
||||
import com.hbm.inventory.SlotPattern;
|
||||
import com.hbm.tileentity.network.pneumatic.TileEntityPneumoStorageMono;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ContainerPneumoStorageMono extends ContainerBase {
|
||||
|
||||
public ContainerPneumoStorageMono(InventoryPlayer invPlayer, TileEntityPneumoStorageMono storage) {
|
||||
super(invPlayer, storage);
|
||||
|
||||
for(int i = 0; i < 3; i++) {
|
||||
this.addSlotToContainer(new SlotPattern(storage, i, 8, 17 + i * 18));
|
||||
}
|
||||
|
||||
playerInv(invPlayer, 99);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int slot) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack slotClick(int index, int button, int mode, EntityPlayer player) {
|
||||
|
||||
//L/R: 0
|
||||
//M3: 3
|
||||
//SHIFT: 1
|
||||
//DRAG: 5
|
||||
|
||||
if(index < 0 || index >= 3) {
|
||||
return super.slotClick(index, button, mode, player);
|
||||
}
|
||||
|
||||
TileEntityPneumoStorageMono mono = (TileEntityPneumoStorageMono) this.tile;
|
||||
if(mono.amounts[index] > 0) return null;
|
||||
|
||||
Slot slot = this.getSlot(index);
|
||||
|
||||
ItemStack ret = null;
|
||||
ItemStack held = player.inventory.getItemStack();
|
||||
|
||||
if(slot.getHasStack()) ret = slot.getStack().copy();
|
||||
slot.putStack(held);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@ -137,7 +137,7 @@ public class GUIPneumoStorageAccess extends GuiInfoContainer {
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int i, int j) {
|
||||
String name = "container.pneumoStorageAccess";
|
||||
String name = I18n.format("container.pneumoStorageAccess");
|
||||
|
||||
this.fontRendererObj.drawString(name, 34 + 176 / 2 - this.fontRendererObj.getStringWidth(name) / 2, 5, 4210752);
|
||||
this.fontRendererObj.drawString(I18n.format("container.inventory"), 34 + 8, this.ySize - 96 + 2, 4210752);
|
||||
|
||||
@ -3,8 +3,10 @@ package com.hbm.inventory.gui;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.hbm.inventory.container.ContainerPneumoStorageClutter;
|
||||
import com.hbm.inventory.gui.element.GUIElements;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.tileentity.network.pneumatic.TileEntityPneumoStorageClutter;
|
||||
import com.hbm.tileentity.network.pneumatic.TileEntityPneumoTube;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
@ -27,11 +29,15 @@ public class GUIPneumoStorageClutter extends GuiInfoContainer {
|
||||
@Override
|
||||
public void drawScreen(int x, int y, float interp) {
|
||||
super.drawScreen(x, y, interp);
|
||||
|
||||
this.drawCustomInfoStat(x, y, guiLeft + 174, guiTop + 36, 20, 8, x, y, "Compressor: " + storage.compair.getPressure() + " PU", "Max range: " + TileEntityPneumoTube.getRangeFromPressure(storage.compair.getPressure()) + "m");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int x, int y, int i) {
|
||||
super.mouseClicked(x, y, i);
|
||||
|
||||
clickSendFlag(storage, x, y, 174, 36, 20, 8, "pressure");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -47,5 +53,8 @@ public class GUIPneumoStorageClutter extends GuiInfoContainer {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
|
||||
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
|
||||
|
||||
drawTexturedModalRect(guiLeft + 174 + 4 * (storage.compair.getPressure() - 1), guiTop + 36, 200, 0, 4, 8);
|
||||
GUIElements.drawSmoothGauge(guiLeft + 184, guiTop + 25, this.zLevel, (double) storage.compair.getFill() / (double) storage.compair.getMaxFill(), 5, 2, 1, 0xCA6C43, 0xAB4223);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,77 @@
|
||||
package com.hbm.inventory.gui;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.hbm.inventory.container.ContainerPneumoStorageMono;
|
||||
import com.hbm.inventory.gui.element.GUIElements;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.tileentity.network.pneumatic.TileEntityPneumoStorageMono;
|
||||
import com.hbm.tileentity.network.pneumatic.TileEntityPneumoTube;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class GUIPneumoStorageMono extends GuiInfoContainer {
|
||||
|
||||
private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/storage/gui_pneumatic_mono.png");
|
||||
protected TileEntityPneumoStorageMono storage;
|
||||
|
||||
public GUIPneumoStorageMono(InventoryPlayer invPlayer, TileEntityPneumoStorageMono storage) {
|
||||
super(new ContainerPneumoStorageMono(invPlayer, storage));
|
||||
this.storage = storage;
|
||||
|
||||
this.xSize = 200;
|
||||
this.ySize = 181;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int x, int y, float interp) {
|
||||
super.drawScreen(x, y, interp);
|
||||
|
||||
this.drawCustomInfoStat(x, y, guiLeft + 174, guiTop + 36, 20, 8, x, y, "Compressor: " + storage.compair.getPressure() + " PU", "Max range: " + TileEntityPneumoTube.getRangeFromPressure(storage.compair.getPressure()) + "m");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int x, int y, int i) {
|
||||
super.mouseClicked(x, y, i);
|
||||
|
||||
clickSendFlag(storage, x, y, 174, 36, 20, 8, "pressure");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int i, int j) {
|
||||
String name = this.storage.hasCustomInventoryName() ? this.storage.getInventoryName() : I18n.format(this.storage.getInventoryName());
|
||||
|
||||
this.fontRendererObj.drawString(name, 176 / 2 - this.fontRendererObj.getStringWidth(name) / 2, 5, 4210752);
|
||||
this.fontRendererObj.drawString(I18n.format("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
|
||||
|
||||
for(int k = 0; k < 3; k++) {
|
||||
if(this.storage.slots[k] != null) {
|
||||
int amount = this.storage.amounts[k];
|
||||
String percent = " (" + (((int) (amount * 1000D / (double) storage.CAPACITY)) / 10D) + "%)";
|
||||
this.fontRendererObj.drawString(String.format(Locale.US, "%,d", amount) + percent, 50, 22 + k * 18, 0x000000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
|
||||
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
|
||||
|
||||
for(int i = 0; i < 3; i++) {
|
||||
if(this.storage.slots[i] != null) {
|
||||
int bar = this.storage.amounts[i] * 124 / this.storage.CAPACITY;
|
||||
drawTexturedModalRect(guiLeft + 44, guiTop + 17 + i * 18, 0, 181, bar, 16);
|
||||
}
|
||||
}
|
||||
|
||||
drawTexturedModalRect(guiLeft + 174 + 4 * (storage.compair.getPressure() - 1), guiTop + 36, 200, 0, 4, 8);
|
||||
GUIElements.drawSmoothGauge(guiLeft + 184, guiTop + 25, this.zLevel, (double) storage.compair.getFill() / (double) storage.compair.getMaxFill(), 5, 2, 1, 0xCA6C43, 0xAB4223);
|
||||
}
|
||||
}
|
||||
@ -8,17 +8,13 @@ import com.hbm.inventory.container.ContainerPneumoTube;
|
||||
import com.hbm.inventory.gui.element.GUIElements;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.module.ModulePatternMatcher;
|
||||
import com.hbm.packet.PacketDispatcher;
|
||||
import com.hbm.packet.toserver.NBTControlPacket;
|
||||
import com.hbm.tileentity.network.pneumatic.TileEntityPneumoTube;
|
||||
import com.hbm.uninos.networkproviders.PneumaticNetwork;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
@ -68,22 +64,13 @@ public class GUIPneumoTube extends GuiInfoContainer {
|
||||
super.mouseClicked(x, y, i);
|
||||
|
||||
if(!endpointOnly) {
|
||||
click(x, y, 7, 52, 18, 18, "redstone");
|
||||
click(x, y, 6, 36, 20, 8, "pressure");
|
||||
click(x, y, 151, 16, 18, 18, "receive");
|
||||
click(x, y, 151, 52, 18, 18, "send");
|
||||
clickSendFlag(tube, x, y, 7, 52, 18, 18, "redstone");
|
||||
clickSendFlag(tube, x, y, 6, 36, 20, 8, "pressure");
|
||||
clickSendFlag(tube, x, y, 151, 16, 18, 18, "receive");
|
||||
clickSendFlag(tube, x, y, 151, 52, 18, 18, "send");
|
||||
}
|
||||
|
||||
click(x, y, 128, 30, 14, 26, "whitelist");
|
||||
}
|
||||
|
||||
public void click(int x, int y, int left, int top, int sizeX, int sizeY, String name) {
|
||||
if(checkClick(x, y, left, top, sizeX, sizeY)) {
|
||||
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setBoolean(name, true);
|
||||
PacketDispatcher.wrapper.sendToServer(new NBTControlPacket(data, tube.xCoord, tube.yCoord, tube.zCoord));
|
||||
}
|
||||
clickSendFlag(tube, x, y, 128, 30, 14, 26, "whitelist");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -328,6 +328,15 @@ public abstract class GuiInfoContainer extends GuiContainer implements INEIGuiHa
|
||||
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
|
||||
}
|
||||
|
||||
public void clickSendFlag(TileEntity tile, int x, int y, int left, int top, int sizeX, int sizeY, String name) {
|
||||
if(checkClick(x, y, left, top, sizeX, sizeY)) {
|
||||
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setBoolean(name, true);
|
||||
PacketDispatcher.wrapper.sendToServer(new NBTControlPacket(data, tile.xCoord, tile.yCoord, tile.zCoord));
|
||||
}
|
||||
}
|
||||
|
||||
///NEI drag and drop support
|
||||
@Override
|
||||
@Optional.Method(modid = "NotEnoughItems")
|
||||
|
||||
@ -74,8 +74,8 @@ public class RenderRBMKGauge extends TileEntitySpecialRenderer {
|
||||
int height = font.FONT_HEIGHT;
|
||||
|
||||
double lineScale = 0.0025D;
|
||||
String lineLower = unit.min <= 10_000 ? unit.min + "" : BobMathUtil.getShortNumber(unit.min);
|
||||
String lineUpper = unit.max <= 10_000 ? unit.max + "" : BobMathUtil.getShortNumber(unit.max);
|
||||
String lineLower = Math.abs(unit.min) <= 10_000 ? unit.min + "" : BobMathUtil.getShortNumber(unit.min);
|
||||
String lineUpper = Math.abs(unit.max) <= 10_000 ? unit.max + "" : BobMathUtil.getShortNumber(unit.max);
|
||||
|
||||
for(int j = 0; j < 2; j++) {
|
||||
GL11.glPushMatrix();
|
||||
|
||||
@ -47,6 +47,7 @@ public class TileEntityDoorGeneric extends TileEntityLockableBase {
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
if(this.getBlockMetadata() < 12) return;
|
||||
|
||||
if(getDoorType().onDoorUpdate() != null) {
|
||||
getDoorType().onDoorUpdate().accept(this);
|
||||
|
||||
@ -59,6 +59,7 @@ import com.hbm.tileentity.machine.storage.*;
|
||||
import com.hbm.tileentity.network.*;
|
||||
import com.hbm.tileentity.network.pneumatic.TileEntityPneumoStorageAccess;
|
||||
import com.hbm.tileentity.network.pneumatic.TileEntityPneumoStorageClutter;
|
||||
import com.hbm.tileentity.network.pneumatic.TileEntityPneumoStorageMono;
|
||||
import com.hbm.tileentity.network.pneumatic.TileEntityPneumoTube;
|
||||
import com.hbm.tileentity.turret.*;
|
||||
import com.hbm.util.Compat;
|
||||
@ -474,6 +475,7 @@ public class TileMappings {
|
||||
put(TileEntityPneumoTubePaintable.class, "tileentity_pneumatic_tube_paintable");
|
||||
put(TileEntityPneumoStorageAccess.class, "tileentity_pneumatic_storage_access");
|
||||
put(TileEntityPneumoStorageClutter.class, "tileentity_pneumatic_storage_clutter");
|
||||
put(TileEntityPneumoStorageMono.class, "tileentity_pneumatic_storage_mono");
|
||||
|
||||
put(TileEntityRadioTorchSender.class, "tileentity_rtty_sender");
|
||||
put(TileEntityRadioTorchReceiver.class, "tileentity_rtty_rec");
|
||||
|
||||
@ -0,0 +1,183 @@
|
||||
package com.hbm.tileentity.network.pneumatic;
|
||||
|
||||
import com.hbm.interfaces.IControlReceiver;
|
||||
import com.hbm.inventory.fluid.Fluids;
|
||||
import com.hbm.inventory.fluid.tank.FluidTank;
|
||||
import com.hbm.tileentity.IGUIProvider;
|
||||
import com.hbm.tileentity.TileEntityMachineBase;
|
||||
import com.hbm.tileentity.network.pneumatic.TileEntityPneumoTube.PneumaticNode;
|
||||
import com.hbm.uninos.UniNodespace;
|
||||
import com.hbm.uninos.networkproviders.PneumaticNetwork;
|
||||
import com.hbm.uninos.networkproviders.PneumaticNetworkProvider;
|
||||
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||
|
||||
import api.hbm.fluidmk2.IFluidStandardReceiverMK2;
|
||||
import api.hbm.ntl.IPneumaticConnector;
|
||||
import api.hbm.ntl.ISlotMonitorProvider;
|
||||
import api.hbm.ntl.SlotMonitor;
|
||||
import api.hbm.ntl.StackCache;
|
||||
import api.hbm.ntl.StackCache.CacheSlot;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public abstract class TileEntityPneumaticStorageBase extends TileEntityMachineBase implements IPneumaticConnector, IFluidStandardReceiverMK2, ISlotMonitorProvider, IControlReceiver, IGUIProvider {
|
||||
|
||||
public FluidTank compair;
|
||||
public SlotMonitor[] monitors;
|
||||
|
||||
protected PneumaticNode node;
|
||||
protected boolean wasAvailable = false;
|
||||
|
||||
public TileEntityPneumaticStorageBase(int slots) {
|
||||
super(slots);
|
||||
this.compair = new FluidTank(Fluids.AIR, 4_000).withPressure(1);
|
||||
this.monitors = new SlotMonitor[slots];
|
||||
|
||||
for(int i = 0; i < monitors.length; i++) this.monitors[i] = new SlotMonitor(i, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(EntityPlayer player) {
|
||||
return this.isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveControl(NBTTagCompound data) {
|
||||
|
||||
if(data.hasKey("pressure")) {
|
||||
int pressure = this.compair.getPressure() + 1;
|
||||
if(pressure > 5) pressure = 1;
|
||||
this.compair.setTankType(Fluids.AIR);
|
||||
this.compair.withPressure(pressure);
|
||||
for(SlotMonitor monitor : this.monitors) monitor.availabilityHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
|
||||
boolean isAvailable = this.isAvailable();
|
||||
|
||||
if(isAvailable != wasAvailable) {
|
||||
this.wasAvailable = isAvailable;
|
||||
for(SlotMonitor monitor : monitors) monitor.availabilityHasChanged();
|
||||
}
|
||||
|
||||
if(this.node == null || this.node.expired) {
|
||||
this.node = (PneumaticNode) UniNodespace.getNode(worldObj, xCoord, yCoord, zCoord, PneumaticNetworkProvider.THE_PROVIDER);
|
||||
|
||||
if(this.node == null || this.node.expired) {
|
||||
this.node = (PneumaticNode) new PneumaticNode(new BlockPos(xCoord, yCoord, zCoord)).setStandardConnections(xCoord, yCoord, zCoord);
|
||||
UniNodespace.createNode(worldObj, this.node);
|
||||
}
|
||||
}
|
||||
|
||||
if(node != null && !node.expired && node.hasValidNet()) {
|
||||
this.node.net.storages.add(this);
|
||||
}
|
||||
|
||||
if(worldObj.getTotalWorldTime() % 10 == 0) for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
this.trySubscribe(compair.getTankType(), worldObj, xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir);
|
||||
}
|
||||
|
||||
if(this.compair.getFill() > 0) {
|
||||
int consumption = (int) Math.ceil(this.compair.getFill() * 17 / this.compair.getMaxFill()) + 3;
|
||||
this.compair.setFill(Math.max(this.compair.getFill() - consumption, 0));
|
||||
}
|
||||
|
||||
this.updateMonitors();
|
||||
this.networkPackNT(15);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isAvailable() {
|
||||
return this.isLoaded && !this.isInvalid() && this.compair.getFill() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
super.invalidate();
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
|
||||
for(SlotMonitor monitor : this.monitors) {
|
||||
for(CacheSlot cache : monitor.viewedBy) cache.removeMonitor(monitor);
|
||||
}
|
||||
|
||||
if(this.node != null) {
|
||||
|
||||
if(node.hasValidNet()) {
|
||||
this.node.net.storages.remove(this);
|
||||
}
|
||||
|
||||
UniNodespace.destroyNode(worldObj, xCoord, yCoord, zCoord, PneumaticNetworkProvider.THE_PROVIDER);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload() {
|
||||
super.onChunkUnload();
|
||||
|
||||
for(SlotMonitor monitor : this.monitors) {
|
||||
for(CacheSlot cache : monitor.viewedBy) cache.removeMonitor(monitor);
|
||||
}
|
||||
|
||||
if(node != null && node.hasValidNet()) {
|
||||
this.node.net.storages.remove(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(ByteBuf buf) {
|
||||
super.serialize(buf);
|
||||
compair.serialize(buf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuf buf) {
|
||||
super.deserialize(buf);
|
||||
compair.deserialize(buf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
this.compair.readFromNBT(nbt, "tank");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
this.compair.writeToNBT(nbt, "tank");
|
||||
}
|
||||
|
||||
@Override public boolean isItemValidForSlot(int slot, ItemStack stack) { return true; }
|
||||
|
||||
@Override public FluidTank[] getAllTanks() { return new FluidTank[] {compair}; }
|
||||
@Override public FluidTank[] getReceivingTanks() { return new FluidTank[] {compair}; }
|
||||
|
||||
@Override public SlotMonitor[] getMonitors() { return monitors; }
|
||||
@Override public ItemStack getSlotAt(int index) { return this.getStackInSlot(index); }
|
||||
|
||||
@Override
|
||||
public PneumaticNetwork getRelevantNetwork() {
|
||||
if(this.node == null || this.node.expired || !this.node.hasValidNet()) return null;
|
||||
return this.node.net;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailableToCache(StackCache cache) {
|
||||
if(!isAvailable()) return false;
|
||||
int range = TileEntityPneumoTube.getRangeFromPressure(this.compair.getPressure());
|
||||
int dX = xCoord - cache.x;
|
||||
int dY = yCoord - cache.y;
|
||||
int dZ = zCoord - cache.z;
|
||||
return dX * dX + dY * dY + dZ * dZ <= range * range;
|
||||
}
|
||||
}
|
||||
@ -1,42 +1,22 @@
|
||||
package com.hbm.tileentity.network.pneumatic;
|
||||
|
||||
import com.hbm.interfaces.IControlReceiver;
|
||||
import com.hbm.inventory.container.ContainerPneumoStorageClutter;
|
||||
import com.hbm.inventory.fluid.Fluids;
|
||||
import com.hbm.inventory.fluid.tank.FluidTank;
|
||||
import com.hbm.inventory.gui.GUIPneumoStorageClutter;
|
||||
import com.hbm.tileentity.IGUIProvider;
|
||||
import com.hbm.tileentity.TileEntityMachineBase;
|
||||
import com.hbm.tileentity.network.pneumatic.TileEntityPneumoTube.PneumaticNode;
|
||||
import com.hbm.uninos.UniNodespace;
|
||||
import com.hbm.uninos.networkproviders.PneumaticNetwork;
|
||||
import com.hbm.uninos.networkproviders.PneumaticNetworkProvider;
|
||||
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||
|
||||
import api.hbm.fluidmk2.IFluidStandardReceiverMK2;
|
||||
import api.hbm.ntl.IPneumaticConnector;
|
||||
import api.hbm.ntl.ISlotMonitorProvider;
|
||||
import api.hbm.ntl.SlotMonitor;
|
||||
import api.hbm.ntl.StackCache;
|
||||
import api.hbm.ntl.StackCache.CacheSlot;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class TileEntityPneumoStorageClutter extends TileEntityMachineBase implements IPneumaticConnector, IFluidStandardReceiverMK2, ISlotMonitorProvider, IGUIProvider {
|
||||
|
||||
public FluidTank compair;
|
||||
public SlotMonitor[] monitors;
|
||||
|
||||
protected PneumaticNode node;
|
||||
protected boolean wasAvailable = false;
|
||||
public class TileEntityPneumoStorageClutter extends TileEntityPneumaticStorageBase implements IPneumaticConnector, IFluidStandardReceiverMK2, ISlotMonitorProvider, IControlReceiver, IGUIProvider {
|
||||
|
||||
public TileEntityPneumoStorageClutter() {
|
||||
super(6 * 9);
|
||||
this.compair = new FluidTank(Fluids.AIR, 4_000).withPressure(1);
|
||||
this.monitors = new SlotMonitor[6 * 9];
|
||||
|
||||
for(int i = 0; i < monitors.length; i++) this.monitors[i] = new SlotMonitor(i, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -44,79 +24,6 @@ public class TileEntityPneumoStorageClutter extends TileEntityMachineBase implem
|
||||
return "container.pneumoStorageClutter";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
|
||||
boolean isAvailable = this.isAvailable();
|
||||
|
||||
if(isAvailable != wasAvailable) {
|
||||
this.wasAvailable = isAvailable;
|
||||
for(SlotMonitor monitor : monitors) monitor.availabilityHasChanged();
|
||||
}
|
||||
|
||||
if(this.node == null || this.node.expired) {
|
||||
this.node = (PneumaticNode) UniNodespace.getNode(worldObj, xCoord, yCoord, zCoord, PneumaticNetworkProvider.THE_PROVIDER);
|
||||
|
||||
if(this.node == null || this.node.expired) {
|
||||
this.node = (PneumaticNode) new PneumaticNode(new BlockPos(xCoord, yCoord, zCoord)).setStandardConnections(xCoord, yCoord, zCoord);
|
||||
UniNodespace.createNode(worldObj, this.node);
|
||||
}
|
||||
}
|
||||
|
||||
if(node != null && !node.expired && node.hasValidNet()) {
|
||||
this.node.net.storages.add(this);
|
||||
}
|
||||
|
||||
this.updateMonitors();
|
||||
this.networkPackNT(15);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isAvailable() {
|
||||
return this.isLoaded && !this.isInvalid();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
super.invalidate();
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
|
||||
for(SlotMonitor monitor : this.monitors) {
|
||||
for(CacheSlot cache : monitor.viewedBy) cache.removeMonitor(monitor);
|
||||
}
|
||||
|
||||
if(this.node != null) {
|
||||
|
||||
if(node.hasValidNet()) {
|
||||
this.node.net.storages.remove(this);
|
||||
}
|
||||
|
||||
UniNodespace.destroyNode(worldObj, xCoord, yCoord, zCoord, PneumaticNetworkProvider.THE_PROVIDER);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload() {
|
||||
super.onChunkUnload();
|
||||
|
||||
for(SlotMonitor monitor : this.monitors) {
|
||||
for(CacheSlot cache : monitor.viewedBy) cache.removeMonitor(monitor);
|
||||
}
|
||||
|
||||
if(node != null && node.hasValidNet()) {
|
||||
this.node.net.storages.remove(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override public boolean isItemValidForSlot(int slot, ItemStack stack) { return true; }
|
||||
|
||||
@Override public FluidTank[] getAllTanks() { return new FluidTank[] {compair}; }
|
||||
@Override public FluidTank[] getReceivingTanks() { return new FluidTank[] {compair}; }
|
||||
|
||||
@Override
|
||||
public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
return new ContainerPneumoStorageClutter(player.inventory, this);
|
||||
@ -127,20 +34,8 @@ public class TileEntityPneumoStorageClutter extends TileEntityMachineBase implem
|
||||
return new GUIPneumoStorageClutter(player.inventory, this);
|
||||
}
|
||||
|
||||
@Override public SlotMonitor[] getMonitors() { return monitors; }
|
||||
@Override public ItemStack getSlotAt(int index) { return this.getStackInSlot(index); }
|
||||
@Override public long getAmountAt(int index) { ItemStack stack = getSlotAt(index); return stack != null ? stack.stackSize : 0; }
|
||||
|
||||
@Override
|
||||
public PneumaticNetwork getRelevantNetwork() {
|
||||
if(this.node == null || this.node.expired || !this.node.hasValidNet()) return null;
|
||||
return this.node.net;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailableToCache(StackCache cache) {
|
||||
return this.isLoaded && !this.isInvalid();
|
||||
}
|
||||
@Override public boolean allowTypeSetting() { return true; }
|
||||
|
||||
@Override
|
||||
public long useUpItem(int index, long amount) {
|
||||
|
||||
@ -0,0 +1,89 @@
|
||||
package com.hbm.tileentity.network.pneumatic;
|
||||
|
||||
import com.hbm.interfaces.IControlReceiver;
|
||||
import com.hbm.inventory.container.ContainerPneumoStorageMono;
|
||||
import com.hbm.inventory.gui.GUIPneumoStorageMono;
|
||||
import com.hbm.tileentity.IGUIProvider;
|
||||
|
||||
import api.hbm.fluidmk2.IFluidStandardReceiverMK2;
|
||||
import api.hbm.ntl.IPneumaticConnector;
|
||||
import api.hbm.ntl.ISlotMonitorProvider;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class TileEntityPneumoStorageMono extends TileEntityPneumaticStorageBase implements IPneumaticConnector, IFluidStandardReceiverMK2, ISlotMonitorProvider, IControlReceiver, IGUIProvider {
|
||||
|
||||
public static final int CAPACITY = 100_000;
|
||||
public int[] amounts;
|
||||
|
||||
public TileEntityPneumoStorageMono() {
|
||||
super(3);
|
||||
|
||||
this.amounts = new int[this.monitors.length];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "container.pneumoStorageMono";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(ByteBuf buf) {
|
||||
super.serialize(buf);
|
||||
for(int i = 0; i < amounts.length; i++) buf.writeInt(amounts[i]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuf buf) {
|
||||
super.deserialize(buf);
|
||||
for(int i = 0; i < amounts.length; i++) amounts[i]= buf.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
this.amounts = nbt.getIntArray("amounts");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
nbt.setIntArray("amounts", amounts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
return new ContainerPneumoStorageMono(player.inventory, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
return new GUIPneumoStorageMono(player.inventory, this);
|
||||
}
|
||||
|
||||
@Override public long getAmountAt(int index) { return amounts[index]; }
|
||||
@Override public boolean allowTypeSetting() { return false; }
|
||||
|
||||
@Override
|
||||
public long useUpItem(int index, long amount) {
|
||||
if(amounts[index] <= 0) return amount;
|
||||
int toRemove = (int) Math.min(amount, amounts[index]);
|
||||
amounts[index] -= toRemove;
|
||||
return amount - toRemove;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long addItem(int index, long amount) {
|
||||
int capacity = CAPACITY - amounts[index];
|
||||
if(capacity <= 0) return amount;
|
||||
int toAdd = (int) Math.min(amount, capacity);
|
||||
amounts[index] += toAdd;
|
||||
return amount - toAdd;
|
||||
}
|
||||
|
||||
@Override public long setupType(int index, ItemStack zeroStack, long amount) { return amount; }
|
||||
}
|
||||
@ -193,32 +193,34 @@ public class BobMathUtil {
|
||||
}
|
||||
|
||||
public static String getShortNumber(long l) {
|
||||
double res;
|
||||
String magnitude_letter = "";
|
||||
|
||||
if(Math.abs(l) >= Math.pow(10, 18)) {
|
||||
double res;
|
||||
String suffix = "";
|
||||
long abs = Math.abs(l);
|
||||
|
||||
if(abs >= Math.pow(10, 18)) {
|
||||
res = l / Math.pow(10, 18);
|
||||
magnitude_letter = "E";
|
||||
suffix = "E";
|
||||
}
|
||||
else if(Math.abs(l) >= Math.pow(10, 15)) {
|
||||
else if(abs >= Math.pow(10, 15)) {
|
||||
res = l / Math.pow(10, 15);
|
||||
magnitude_letter = "P";
|
||||
suffix = "P";
|
||||
}
|
||||
else if(Math.abs(l) >= Math.pow(10, 12)) {
|
||||
else if(abs >= Math.pow(10, 12)) {
|
||||
res = l / Math.pow(10, 12);
|
||||
magnitude_letter = "T";
|
||||
suffix = "T";
|
||||
}
|
||||
else if(Math.abs(l) >= Math.pow(10, 9)) {
|
||||
else if(abs >= Math.pow(10, 9)) {
|
||||
res = l / Math.pow(10, 9);
|
||||
magnitude_letter = "G";
|
||||
suffix = "G";
|
||||
}
|
||||
else if(Math.abs(l) >= Math.pow(10, 6)) {
|
||||
else if(abs >= Math.pow(10, 6)) {
|
||||
res = l / Math.pow(10, 6);
|
||||
magnitude_letter = "M";
|
||||
suffix = "M";
|
||||
}
|
||||
else if(Math.abs(l) >= Math.pow(10, 3)) {
|
||||
else if(abs >= Math.pow(10, 3)) {
|
||||
res = l / Math.pow(10, 3);
|
||||
magnitude_letter = "k";
|
||||
suffix = "k";
|
||||
}
|
||||
else {
|
||||
return Long.toString(l);
|
||||
@ -231,7 +233,7 @@ public class BobMathUtil {
|
||||
res = Math.round(res * 100.0) / 100.0;
|
||||
}
|
||||
|
||||
return res + magnitude_letter;
|
||||
return res + suffix;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -357,6 +357,8 @@ container.paDipole=Dipol
|
||||
container.paQuadrupole=Quad.
|
||||
container.paSource=Teilchenquelle
|
||||
container.plasmaHeater=Plasmaerhitzer
|
||||
container.pneumoStorageAccess=PLS Zugangsterminal
|
||||
container.pneumoStorageClutter=PLS Gerümpelkiste
|
||||
container.pneumoTube=Rohrpost
|
||||
container.press=Befeuerte Presse
|
||||
container.puf6_tank=PuF6 Tank
|
||||
@ -4736,6 +4738,8 @@ tile.plant_tall.weed.name=Hanf
|
||||
tile.plasma.name=Plasma
|
||||
tile.plasma_heater.name=Plasmaerhitzer
|
||||
tile.plushie.name=%s Plüschfigur
|
||||
tile.pneumatic_storage_access.name=Pneumatisches Lagersystem - Zugangsterminal
|
||||
tile.pneumatic_storage_clutter.name=Pneumatisches Lagersystem - Gerümpelkiste
|
||||
tile.pneumatic_tube.name=Rohrpost
|
||||
tile.pneumatic_tube.desc=Sendted Items mit Druckluft.$Rechtsklick mit Schraubenzieher aktiviert den Eingang.$Shift-Rechtskick mit Schrabuenzieher aktiviert den Ausgang.$Eingänge können konfiguriert und mit Druckluft verbunden werden.$Sendet bis zu einem Stack, vier Mal pro Sekunde.
|
||||
tile.pneumatic_tube_paintable.name=Geschirmte Rohrpost (Färbbar)
|
||||
|
||||
@ -759,6 +759,8 @@ container.paDipole=Dipole
|
||||
container.paQuadrupole=Quad.
|
||||
container.paSource=Particle Source
|
||||
container.plasmaHeater=Plasma Heater
|
||||
container.pneumoStorageAccess=PSN Access Terminal
|
||||
container.pneumoStorageClutter=PSN Clutter Storage
|
||||
container.pneumoTube=Pneumatic Tube
|
||||
container.press=Burner Press
|
||||
container.puf6_tank=PuF6 Tank
|
||||
@ -5996,6 +5998,8 @@ tile.plant_tall.weed.name=Hemp
|
||||
tile.plasma.name=Plasma
|
||||
tile.plasma_heater.name=Plasma Heater
|
||||
tile.plushie.name=%s Plushie
|
||||
tile.pneumatic_storage_access.name=Pneumatic Storage Network - Access Terminal
|
||||
tile.pneumatic_storage_clutter.name=Pneumatic Storage Network - Clutter Storage
|
||||
tile.pneumatic_tube.name=Pneumatic Tube
|
||||
tile.pneumatic_tube.desc=Sends items using compressed air.$Right-click with screwdriver to toggle an input.$Shift right-click with screwdriver to toggle an output.$Inputs can be configured, and connected to compressed air.$Sends up to one stack, four times per second.
|
||||
tile.pneumatic_tube_paintable.name=Paintable Pneumatic Tube
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
Loading…
x
Reference in New Issue
Block a user