From 7fdd48f29f7161b37d57819d2cb7f9b989e174a4 Mon Sep 17 00:00:00 2001 From: HbmMods Date: Sat, 20 Jun 2026 18:36:37 +0200 Subject: [PATCH] storag --- changelog | 3 +- .../api/hbm/ntl/ISlotMonitorProvider.java | 3 + src/main/java/api/hbm/ntl/StackCache.java | 1 + .../network/pneumatic/PneumoStorageMono.java | 16 +- .../com/hbm/inventory/OreDictManager.java | 2 +- .../container/ContainerPneumoStorageMono.java | 52 +++++ .../inventory/gui/GUIPneumoStorageAccess.java | 2 +- .../gui/GUIPneumoStorageClutter.java | 9 + .../inventory/gui/GUIPneumoStorageMono.java | 77 ++++++++ .../com/hbm/inventory/gui/GUIPneumoTube.java | 23 +-- .../hbm/inventory/gui/GuiInfoContainer.java | 9 + .../render/tileentity/RenderRBMKGauge.java | 4 +- .../hbm/tileentity/TileEntityDoorGeneric.java | 1 + .../java/com/hbm/tileentity/TileMappings.java | 2 + .../TileEntityPneumaticStorageBase.java | 183 ++++++++++++++++++ .../TileEntityPneumoStorageClutter.java | 113 +---------- .../TileEntityPneumoStorageMono.java | 89 +++++++++ src/main/java/com/hbm/util/BobMathUtil.java | 30 +-- src/main/resources/assets/hbm/lang/de_DE.lang | 4 + src/main/resources/assets/hbm/lang/en_US.lang | 4 + .../gui/storage/gui_pneumatic_mono.png | Bin 0 -> 2077 bytes 21 files changed, 480 insertions(+), 147 deletions(-) create mode 100644 src/main/java/com/hbm/inventory/container/ContainerPneumoStorageMono.java create mode 100644 src/main/java/com/hbm/inventory/gui/GUIPneumoStorageMono.java create mode 100644 src/main/java/com/hbm/tileentity/network/pneumatic/TileEntityPneumaticStorageBase.java create mode 100644 src/main/java/com/hbm/tileentity/network/pneumatic/TileEntityPneumoStorageMono.java create mode 100644 src/main/resources/assets/hbm/textures/gui/storage/gui_pneumatic_mono.png diff --git a/changelog b/changelog index c9e872645..a59d61d30 100644 --- a/changelog +++ b/changelog @@ -28,4 +28,5 @@ * Fixed lapis dust to cobalt shredder recipe not using oredict * 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 \ No newline at end of file +* 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 \ No newline at end of file diff --git a/src/main/java/api/hbm/ntl/ISlotMonitorProvider.java b/src/main/java/api/hbm/ntl/ISlotMonitorProvider.java index 8cbdf135b..da57797ba 100644 --- a/src/main/java/api/hbm/ntl/ISlotMonitorProvider.java +++ b/src/main/java/api/hbm/ntl/ISlotMonitorProvider.java @@ -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); diff --git a/src/main/java/api/hbm/ntl/StackCache.java b/src/main/java/api/hbm/ntl/StackCache.java index 225164256..f7ef2fc4b 100644 --- a/src/main/java/api/hbm/ntl/StackCache.java +++ b/src/main/java/api/hbm/ntl/StackCache.java @@ -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; diff --git a/src/main/java/com/hbm/blocks/network/pneumatic/PneumoStorageMono.java b/src/main/java/com/hbm/blocks/network/pneumatic/PneumoStorageMono.java index 47428aff2..898af831e 100644 --- a/src/main/java/com/hbm/blocks/network/pneumatic/PneumoStorageMono.java +++ b/src/main/java/com/hbm/blocks/network/pneumatic/PneumoStorageMono.java @@ -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; + } } \ No newline at end of file diff --git a/src/main/java/com/hbm/inventory/OreDictManager.java b/src/main/java/com/hbm/inventory/OreDictManager.java index ae0b7e181..32fa4d16c 100644 --- a/src/main/java/com/hbm/inventory/OreDictManager.java +++ b/src/main/java/com/hbm/inventory/OreDictManager.java @@ -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"); diff --git a/src/main/java/com/hbm/inventory/container/ContainerPneumoStorageMono.java b/src/main/java/com/hbm/inventory/container/ContainerPneumoStorageMono.java new file mode 100644 index 000000000..5d7523014 --- /dev/null +++ b/src/main/java/com/hbm/inventory/container/ContainerPneumoStorageMono.java @@ -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; + } +} diff --git a/src/main/java/com/hbm/inventory/gui/GUIPneumoStorageAccess.java b/src/main/java/com/hbm/inventory/gui/GUIPneumoStorageAccess.java index f2016b39e..0a904dada 100644 --- a/src/main/java/com/hbm/inventory/gui/GUIPneumoStorageAccess.java +++ b/src/main/java/com/hbm/inventory/gui/GUIPneumoStorageAccess.java @@ -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); diff --git a/src/main/java/com/hbm/inventory/gui/GUIPneumoStorageClutter.java b/src/main/java/com/hbm/inventory/gui/GUIPneumoStorageClutter.java index 39ebd6863..595d31075 100644 --- a/src/main/java/com/hbm/inventory/gui/GUIPneumoStorageClutter.java +++ b/src/main/java/com/hbm/inventory/gui/GUIPneumoStorageClutter.java @@ -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); } } diff --git a/src/main/java/com/hbm/inventory/gui/GUIPneumoStorageMono.java b/src/main/java/com/hbm/inventory/gui/GUIPneumoStorageMono.java new file mode 100644 index 000000000..a4c0fd348 --- /dev/null +++ b/src/main/java/com/hbm/inventory/gui/GUIPneumoStorageMono.java @@ -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); + } +} diff --git a/src/main/java/com/hbm/inventory/gui/GUIPneumoTube.java b/src/main/java/com/hbm/inventory/gui/GUIPneumoTube.java index aa9f968d3..409e522f1 100644 --- a/src/main/java/com/hbm/inventory/gui/GUIPneumoTube.java +++ b/src/main/java/com/hbm/inventory/gui/GUIPneumoTube.java @@ -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 diff --git a/src/main/java/com/hbm/inventory/gui/GuiInfoContainer.java b/src/main/java/com/hbm/inventory/gui/GuiInfoContainer.java index c966dd9f4..f99f75244 100644 --- a/src/main/java/com/hbm/inventory/gui/GuiInfoContainer.java +++ b/src/main/java/com/hbm/inventory/gui/GuiInfoContainer.java @@ -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") diff --git a/src/main/java/com/hbm/render/tileentity/RenderRBMKGauge.java b/src/main/java/com/hbm/render/tileentity/RenderRBMKGauge.java index 0b8052969..55503d662 100644 --- a/src/main/java/com/hbm/render/tileentity/RenderRBMKGauge.java +++ b/src/main/java/com/hbm/render/tileentity/RenderRBMKGauge.java @@ -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(); diff --git a/src/main/java/com/hbm/tileentity/TileEntityDoorGeneric.java b/src/main/java/com/hbm/tileentity/TileEntityDoorGeneric.java index 0e828407d..29bfb46ae 100644 --- a/src/main/java/com/hbm/tileentity/TileEntityDoorGeneric.java +++ b/src/main/java/com/hbm/tileentity/TileEntityDoorGeneric.java @@ -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); diff --git a/src/main/java/com/hbm/tileentity/TileMappings.java b/src/main/java/com/hbm/tileentity/TileMappings.java index b343c854e..0efef5c6c 100644 --- a/src/main/java/com/hbm/tileentity/TileMappings.java +++ b/src/main/java/com/hbm/tileentity/TileMappings.java @@ -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"); diff --git a/src/main/java/com/hbm/tileentity/network/pneumatic/TileEntityPneumaticStorageBase.java b/src/main/java/com/hbm/tileentity/network/pneumatic/TileEntityPneumaticStorageBase.java new file mode 100644 index 000000000..c9dca5229 --- /dev/null +++ b/src/main/java/com/hbm/tileentity/network/pneumatic/TileEntityPneumaticStorageBase.java @@ -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; + } +} diff --git a/src/main/java/com/hbm/tileentity/network/pneumatic/TileEntityPneumoStorageClutter.java b/src/main/java/com/hbm/tileentity/network/pneumatic/TileEntityPneumoStorageClutter.java index 9ee354b43..cc7b1f798 100644 --- a/src/main/java/com/hbm/tileentity/network/pneumatic/TileEntityPneumoStorageClutter.java +++ b/src/main/java/com/hbm/tileentity/network/pneumatic/TileEntityPneumoStorageClutter.java @@ -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); @@ -126,21 +33,9 @@ public class TileEntityPneumoStorageClutter extends TileEntityMachineBase implem public Object provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) { 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) { diff --git a/src/main/java/com/hbm/tileentity/network/pneumatic/TileEntityPneumoStorageMono.java b/src/main/java/com/hbm/tileentity/network/pneumatic/TileEntityPneumoStorageMono.java new file mode 100644 index 000000000..30f7c62e4 --- /dev/null +++ b/src/main/java/com/hbm/tileentity/network/pneumatic/TileEntityPneumoStorageMono.java @@ -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; } +} diff --git a/src/main/java/com/hbm/util/BobMathUtil.java b/src/main/java/com/hbm/util/BobMathUtil.java index a38522a07..5bb09570e 100644 --- a/src/main/java/com/hbm/util/BobMathUtil.java +++ b/src/main/java/com/hbm/util/BobMathUtil.java @@ -193,32 +193,34 @@ public class BobMathUtil { } public static String getShortNumber(long l) { + double res; - String magnitude_letter = ""; + String suffix = ""; + long abs = Math.abs(l); - if(Math.abs(l) >= Math.pow(10, 18)) { + 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; } /** diff --git a/src/main/resources/assets/hbm/lang/de_DE.lang b/src/main/resources/assets/hbm/lang/de_DE.lang index 043478092..5fadd08b5 100644 --- a/src/main/resources/assets/hbm/lang/de_DE.lang +++ b/src/main/resources/assets/hbm/lang/de_DE.lang @@ -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) diff --git a/src/main/resources/assets/hbm/lang/en_US.lang b/src/main/resources/assets/hbm/lang/en_US.lang index 10b6b3264..be081a936 100644 --- a/src/main/resources/assets/hbm/lang/en_US.lang +++ b/src/main/resources/assets/hbm/lang/en_US.lang @@ -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 diff --git a/src/main/resources/assets/hbm/textures/gui/storage/gui_pneumatic_mono.png b/src/main/resources/assets/hbm/textures/gui/storage/gui_pneumatic_mono.png new file mode 100644 index 0000000000000000000000000000000000000000..443b32d5fe72a4d869e09641e1f4b5d839460ac8 GIT binary patch literal 2077 zcmbVN2~ZPO8h%L-Fp6v{P;Rn8F%T$Ti$V$kHZ4jmr-pD0K~e!pkfUHC6cVJY$RUg( zw2L7i1+*ODFhGG2L9Q)lpj45wP_7{%;D$p8$p+VTXFFYIXWz`5_h$Z?@BPR3eebrL zi<25$7Y+bWJAV%E0RTjCg#cA$#o-tAC`fTAed&1qqN-wjrTRq*04hJ7$2(l4KM+j} zP{uZOR92m?!kdIR^ipBHn)&kGETiLSjeS0<2Xp7LDFcusys6Mic+awln(Lrm7~r`W zfOPlK*2vRJJ$mnJKj$;5^sXHLDASh?Ip#ezfxdT(Ir+~II2wD&7Ly(>RAkysaq`1W z@5De;Qqb$NSIacL-Nr51u;uJLiEox6yC2w?AerjtOojEvpsLW54c_8*dsTdNnw&o% zKgHhPH^_C9Mzqzs8sZO@r|{*Hp4XoTbylj&r#o<)^C#4a+5>C^am+Lj3XY831yLVI=yhpdO4=1 zrsiaZsm1;0`Kr<4jf&fb(<^b}F22l;1yUAUkljUoAF;6@Hkt7=<-1Ypr(Ywrf4yLz z)7IMRz+aVDRqG%SMqUJCRG_@}X8|u1Ay9+wYK~K z19CcjcPh3TYIJ!P%wKrSAD@l9;1BDr<=yaxxDk`YGD}R^+D>ek&?J)Uld&C6aUbQv z7ZJcbxqicyUz^)AhtBOOO}M5R(dz`@;yFREJXav(fFI|go{Wi77FV`66DFxvMLIm* zP3sHSTZs_+KmyR1OyY~2@a<&-%e!pum`HXTm$U;N3H_6mRnsllat^IMj7-?xX$ z=&zt>MnczrDw*z_54uS3;zWfW_#C(qF&K=1YBf8uur4zz*sR1ki{+wvA9s$m4%!h^ z9r2I%&r|?Nk^-`K2^h1oGI!2Mf3vFhgCkPRq@o5o*KoW1stNhQQWn?mJdQ#*Yxyjq)gnq=iR6(%Jmi#(|5!Skh zFKv}(s4>GgS~3)ywFof@L!W#!O1(2NcjdKT2_)SShciedhJ3iB+TJk=E67sbkzFbq zIgEMMGv5C)e8?TZ%V;H}a8k(7n9f^%Lcs@zLDn~b*{-krUDjV{;$uA4eNd2fNL}5P zg*?3^N>>8O!y%`K@*7TtL78ojC$_BTikpL5O^^raEj!VZo(&#~Hha`LvNSOOzF?Lr zf5u@bMA;`zobQD*+ic8+yuG()G6xYUGkU&{T=PF(!t0;ezhqz=!u2tQOJkyy0t>H# zQ@%FP>cMEGzgpxm-=w4TTP3~8)VyNy>eB~(xryi}f7kdSEjhmr&MdYfN?)e1g7(=L zvNk8;tG40~uPTK2nd=%`5p`_puJK=EE28jJ#%Y5@^yy^VZ>u4z!c5Iuu_Ivxc1kPM4(j&=Q_bl6?4@#n`EQ~v<< zjI_|e?W=8S(!1PYqgkvCXYzQw*L}+Umnjqs3RPEMZ(Ocq5;fBVQjMb4t{~qy$iFA_ z`z^_O@qz-gOOVoMREWO5X)Kn(toFjt>^LuuHWR5GMg{n2ImD#8rNt17#dex*StiyrTWgw|JSEVFjaf$203{Jz@5CNm)^Cyz%90iQ8F8g&vq{M2&U1V zE4U;ffMP6dMe$2TAgn+sd27G0_lj0TWGVyh%(%0d{cwls-@&FBQm$pvBv|+@yZ6fD i_ms28$^Ua5r^r>v&B3)_S_9WTi1VMg;42*iZvF$-PHwya literal 0 HcmV?d00001