diff --git a/changelog b/changelog index 58d91a5fb..438300216 100644 --- a/changelog +++ b/changelog @@ -14,4 +14,5 @@ * Fixed incorrect tooltip in the automatic control rod's GUI * Fixed recipe autogen creating recipes for nonexistant thorium bedrock ore * Fixed FBI agents spawning both the old and new bullet entities when firing -* Fixed dupe concerning one of the weapon abilities \ No newline at end of file +* Fixed dupe concerning one of the weapon abilities +* Fixed crates not sending a block update when the contents change, breaking redstone comparator functionality \ No newline at end of file diff --git a/src/main/java/com/hbm/inventory/container/ContainerPASource.java b/src/main/java/com/hbm/inventory/container/ContainerPASource.java new file mode 100644 index 000000000..90e01d5c4 --- /dev/null +++ b/src/main/java/com/hbm/inventory/container/ContainerPASource.java @@ -0,0 +1,77 @@ +package com.hbm.inventory.container; + +import com.hbm.inventory.SlotTakeOnly; +import com.hbm.items.ModItems; +import com.hbm.tileentity.machine.albion.TileEntityPASource; + +import api.hbm.energymk2.IBatteryItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class ContainerPASource extends Container { + + private TileEntityPASource source; + + public ContainerPASource(InventoryPlayer playerInv, TileEntityPASource tile) { + source = tile; + + //Battery + this.addSlotToContainer(new Slot(tile, 0, 8, 72)); + //Inouts + this.addSlotToContainer(new Slot(tile, 1, 62, 18)); + this.addSlotToContainer(new Slot(tile, 2, 80, 18)); + //Containers + this.addSlotToContainer(new SlotTakeOnly(tile, 3, 62, 45)); + this.addSlotToContainer(new SlotTakeOnly(tile, 4, 80, 45)); + + for(int i = 0; i < 3; i++) { + for(int j = 0; j < 9; j++) { + this.addSlotToContainer(new Slot(playerInv, j + i * 9 + 9, 8 + j * 18, 122 + i * 18)); + } + } + + for(int i = 0; i < 9; i++) { + this.addSlotToContainer(new Slot(playerInv, i, 8 + i * 18, 180)); + } + } + + @Override + public boolean canInteractWith(EntityPlayer player) { + return source.isUseableByPlayer(player); + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int index) { + ItemStack rStack = null; + Slot slot = (Slot) this.inventorySlots.get(index); + + if(slot != null && slot.getHasStack()) { + ItemStack stack = slot.getStack(); + rStack = stack.copy(); + + if(index <= 5) { + if(!this.mergeItemStack(stack, 6, this.inventorySlots.size(), true)) { + return null; + } + } else { + + if(rStack.getItem() instanceof IBatteryItem || rStack.getItem() == ModItems.battery_creative) { + if(!this.mergeItemStack(stack, 0, 1, false)) return null; + } else { + if(!this.mergeItemStack(stack, 1, 3, false)) return null; + } + } + + if(stack.stackSize == 0) { + slot.putStack((ItemStack) null); + } else { + slot.onSlotChanged(); + } + } + + return rStack; + } +} diff --git a/src/main/java/com/hbm/inventory/gui/GUIPADipole.java b/src/main/java/com/hbm/inventory/gui/GUIPADipole.java index 09920e519..ae4650f2f 100644 --- a/src/main/java/com/hbm/inventory/gui/GUIPADipole.java +++ b/src/main/java/com/hbm/inventory/gui/GUIPADipole.java @@ -18,9 +18,9 @@ public class GUIPADipole extends GuiInfoContainer { private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/particleaccelerator/gui_dipole.png"); private TileEntityPADipole dipole; - public GUIPADipole(InventoryPlayer player, TileEntityPADipole slopper) { - super(new ContainerPADipole(player, slopper)); - this.dipole = slopper; + public GUIPADipole(InventoryPlayer player, TileEntityPADipole dipole) { + super(new ContainerPADipole(player, dipole)); + this.dipole = dipole; this.xSize = 176; this.ySize = 204; diff --git a/src/main/java/com/hbm/inventory/gui/GUIPASource.java b/src/main/java/com/hbm/inventory/gui/GUIPASource.java new file mode 100644 index 000000000..667950c4f --- /dev/null +++ b/src/main/java/com/hbm/inventory/gui/GUIPASource.java @@ -0,0 +1,65 @@ + package com.hbm.inventory.gui; + +import org.lwjgl.opengl.GL11; + +import com.hbm.inventory.container.ContainerPASource; +import com.hbm.lib.RefStrings; +import com.hbm.tileentity.machine.albion.TileEntityPASource; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; + +public class GUIPASource extends GuiInfoContainer { + + private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/particleaccelerator/gui_source.png"); + private TileEntityPASource source; + + public GUIPASource(InventoryPlayer player, TileEntityPASource source) { + super(new ContainerPASource(player, source)); + this.source = source; + + this.xSize = 176; + this.ySize = 204; + } + + @Override + public void drawScreen(int mouseX, int mouseY, float f) { + super.drawScreen(mouseX, mouseY, f); + + source.tanks[0].renderTankInfo(this, mouseX, mouseY, guiLeft + 134, guiTop + 36, 16, 52); + source.tanks[1].renderTankInfo(this, mouseX, mouseY, guiLeft + 152, guiTop + 36, 16, 52); + this.drawElectricityInfo(this, mouseX, mouseY, guiLeft + 8, guiTop + 18, 16, 52, source.power, source.getMaxPower()); + } + + @Override + protected void drawGuiContainerForegroundLayer( int i, int j) { + + String name = this.source.hasCustomInventoryName() ? this.source.getInventoryName() : I18n.format(this.source.getInventoryName()); + this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2 - 9, 6, 4210752); + this.fontRendererObj.drawString(I18n.format("container.inventory"), 8, this.ySize - 96 + 2, 4210752); + + this.fontRendererObj.drawString(EnumChatFormatting.AQUA + "/123K", 136, 22, 4210752); + int heat = (int) Math.ceil(source.temperature); + String label = (heat > 123 ? EnumChatFormatting.RED : EnumChatFormatting.AQUA) + "" + heat + "K"; + this.fontRendererObj.drawString(label, 166 - this.fontRendererObj.getStringWidth(label), 12, 4210752); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float interp, int x, int y) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + Minecraft.getMinecraft().getTextureManager().bindTexture(texture); + drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); + + int j = (int) (source.power * 52 / source.getMaxPower()); + drawTexturedModalRect(guiLeft + 8, guiTop + 70 - j, 184, 52 - j, 16, j); + + int heat = (int) Math.ceil(source.temperature); + if(heat <= 123) drawTexturedModalRect(guiLeft + 44, guiTop + 18, 176, 8, 8, 8); + + source.tanks[0].renderTank(guiLeft + 134, guiTop + 88, this.zLevel, 16, 52); + source.tanks[1].renderTank(guiLeft + 152, guiTop + 88, this.zLevel, 16, 52); + } +} diff --git a/src/main/java/com/hbm/qmaw/QMAWLoader.java b/src/main/java/com/hbm/qmaw/QMAWLoader.java index c181bb29f..955873a66 100644 --- a/src/main/java/com/hbm/qmaw/QMAWLoader.java +++ b/src/main/java/com/hbm/qmaw/QMAWLoader.java @@ -3,8 +3,6 @@ package com.hbm.qmaw; import java.io.File; import java.io.InputStream; import java.io.InputStreamReader; -import java.net.URL; -import java.security.CodeSource; import java.util.HashMap; import java.util.HashSet; import java.util.zip.ZipEntry; diff --git a/src/main/java/com/hbm/tileentity/machine/albion/TileEntityPASource.java b/src/main/java/com/hbm/tileentity/machine/albion/TileEntityPASource.java index c4937c86b..6a4f5fe30 100644 --- a/src/main/java/com/hbm/tileentity/machine/albion/TileEntityPASource.java +++ b/src/main/java/com/hbm/tileentity/machine/albion/TileEntityPASource.java @@ -1,5 +1,7 @@ package com.hbm.tileentity.machine.albion; +import com.hbm.inventory.container.ContainerPASource; +import com.hbm.inventory.gui.GUIPASource; import com.hbm.tileentity.IGUIProvider; import com.hbm.util.fauxpointtwelve.DirPos; @@ -60,11 +62,11 @@ public class TileEntityPASource extends TileEntityCooledBase implements IGUIProv @Override public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) { - return null; + return new ContainerPASource(player.inventory, this); } @Override public Object provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) { - return null; + return new GUIPASource(player.inventory, this); } } diff --git a/src/main/java/com/hbm/tileentity/machine/storage/TileEntityCrateBase.java b/src/main/java/com/hbm/tileentity/machine/storage/TileEntityCrateBase.java index 3bdf405c2..5e40a51c5 100644 --- a/src/main/java/com/hbm/tileentity/machine/storage/TileEntityCrateBase.java +++ b/src/main/java/com/hbm/tileentity/machine/storage/TileEntityCrateBase.java @@ -45,6 +45,7 @@ public abstract class TileEntityCrateBase extends TileEntityLockableBase impleme if (itemStack != null && itemStack.stackSize > getInventoryStackLimit()) { itemStack.stackSize = getInventoryStackLimit(); } + this.markDirty(); } @Override @@ -98,6 +99,7 @@ public abstract class TileEntityCrateBase extends TileEntityLockableBase impleme slots[i] = null; } + this.markDirty(); return itemStack1; } else { return null; diff --git a/src/main/resources/assets/hbm/textures/gui/particleaccelerator/gui_detector.png b/src/main/resources/assets/hbm/textures/gui/particleaccelerator/gui_detector.png index dad73a553..db202f440 100644 Binary files a/src/main/resources/assets/hbm/textures/gui/particleaccelerator/gui_detector.png and b/src/main/resources/assets/hbm/textures/gui/particleaccelerator/gui_detector.png differ