some things
|
@ -8,15 +8,9 @@ import techreborn.lib.ModInfo;
|
|||
|
||||
public class ArmorSlot extends FilteredSlot {
|
||||
|
||||
public ArmorSlot(final EntityEquipmentSlot armorType, final InventoryPlayer inventory, final int index,
|
||||
final int xPosition, final int yPosition) {
|
||||
|
||||
public ArmorSlot(final EntityEquipmentSlot armorType, final InventoryPlayer inventory, final int index, final int xPosition, final int yPosition) {
|
||||
super(inventory, index, xPosition, yPosition);
|
||||
|
||||
this.setFilter(stack -> stack != null && stack.getItem().isValidArmor(stack, armorType, inventory.player));
|
||||
|
||||
this.setBackgroundLocation(
|
||||
new ResourceLocation(ModInfo.MOD_ID, "textures/gui/slots/armor_" + armorType.getName() + ".png"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -2,25 +2,15 @@ package techreborn.client.container.builder.slot;
|
|||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
|
||||
import reborncore.api.power.IEnergyInterfaceItem;
|
||||
|
||||
import techreborn.lib.ModInfo;
|
||||
|
||||
public class EnergyChargeSlot extends FilteredSlot {
|
||||
|
||||
private static final ResourceLocation TEX = new ResourceLocation(ModInfo.MOD_ID,
|
||||
"textures/gui/slots/energy_charge.png");
|
||||
|
||||
@SuppressWarnings("null")
|
||||
public EnergyChargeSlot(final IInventory inventory, final int index, final int xPosition, final int yPosition) {
|
||||
super(inventory, index, xPosition, yPosition);
|
||||
|
||||
this.setFilter(stack -> stack.hasCapability(CapabilityEnergy.ENERGY, EnumFacing.UP)
|
||||
|| stack.getItem() instanceof IEnergyInterfaceItem);
|
||||
this.setBackgroundLocation(EnergyChargeSlot.TEX);
|
||||
this.setFilter(stack -> stack.hasCapability(CapabilityEnergy.ENERGY, EnumFacing.UP) || stack.getItem() instanceof IEnergyInterfaceItem);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,6 +21,10 @@ public class FilteredSlot extends Slot {
|
|||
|
||||
@Override
|
||||
public boolean isItemValid(final ItemStack stack) {
|
||||
return this.filter.test(stack);
|
||||
try {
|
||||
return this.filter.test(stack);
|
||||
} catch (NullPointerException e) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
package techreborn.client.container.builder.slot;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import techreborn.lib.ModInfo;
|
||||
|
||||
public class SpriteSlot extends FilteredSlot {
|
||||
|
||||
int stacksize;
|
||||
|
||||
public SpriteSlot(final IInventory inventory, final int index, final int xPosition, final int yPosition, String sprite, int stacksize) {
|
||||
super(inventory, index, xPosition, yPosition);
|
||||
this.setBackgroundLocation(new ResourceLocation(ModInfo.MOD_ID.toLowerCase() + ":textures/gui/slot_sprites/" + sprite + ".png"));
|
||||
this.stacksize = stacksize;
|
||||
}
|
||||
|
||||
public SpriteSlot(final IInventory inventory, final int index, final int xPosition, final int yPosition, String sprite) {
|
||||
this(inventory, index, xPosition, yPosition, sprite, 64);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlotStackLimit() {
|
||||
return stacksize;
|
||||
}
|
||||
}
|
|
@ -80,4 +80,10 @@ public class GuiBase extends GuiContainer {
|
|||
mc.fontRendererObj.drawString(string, x, y, colour);
|
||||
GlStateManager.color(1, 1, 1, 1);
|
||||
}
|
||||
|
||||
//TODO
|
||||
public enum SlotRender {
|
||||
STANDARD, OUTPUT, NONE, SPRITE;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ public class GuiDigitalChest extends GuiBase {
|
|||
TileDigitalChest tile;
|
||||
|
||||
public GuiDigitalChest(final EntityPlayer player, final TileDigitalChest tile) {
|
||||
super(player, tile, new ContainerBuilder().player(player.inventory).inventory().hotbar().addInventory().tile(tile).slot(0, 80, 20).outputSlot(1, 80, 70).fakeSlot(2, 80, 45).addInventory().create());
|
||||
super(player, tile, new ContainerBuilder().player(player.inventory).inventory().hotbar().addInventory().tile(tile).slot(0, 80, 24).outputSlot(1, 80, 64).addInventory().create());
|
||||
this.tile = tile;
|
||||
}
|
||||
|
||||
|
@ -18,18 +18,17 @@ public class GuiDigitalChest extends GuiBase {
|
|||
protected void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) {
|
||||
super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY);
|
||||
|
||||
drawSlotBackground(80, 20);
|
||||
drawSelectedStackBackground(80, 45);
|
||||
drawSlotBackground(80, 70);
|
||||
drawSlotBackground(80, 24);
|
||||
drawSlotBackground(80, 64);
|
||||
}
|
||||
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
this.fontRendererObj.drawString("Amount", 105, 43, 0);
|
||||
if (tile.storedItem != ItemStack.EMPTY && tile.getStackInSlot(1) != null) {
|
||||
drawString(tile.storedItem.getCount() + tile.getStackInSlot(1).getCount() + "", 105, 53, 0);
|
||||
builder.drawBigBlueBar(this, 31, 43, tile.storedItem.getCount() + tile.getStackInSlot(1).getCount(), tile.maxCapacity, mouseX - guiLeft, mouseY - guiTop, "Stored");
|
||||
}
|
||||
if (tile.storedItem == ItemStack.EMPTY && tile.getStackInSlot(1) != null) {
|
||||
builder.drawBigBlueBar(this, 31, 43, tile.getStackInSlot(1).getCount(), tile.maxCapacity, mouseX - guiLeft, mouseY - guiTop, "Stored");
|
||||
}
|
||||
if (tile.storedItem == ItemStack.EMPTY && tile.getStackInSlot(1) != null)
|
||||
drawString(tile.getStackInSlot(1).getCount() + "", 105, 53, 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package techreborn.client.gui;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
@ -18,13 +17,12 @@ import java.util.List;
|
|||
*/
|
||||
public class TRBuilder extends GuiBuilder {
|
||||
public static final ResourceLocation GUI_SHEET = new ResourceLocation(ModInfo.MOD_ID.toLowerCase() + ":" + "textures/gui/gui_sheet.png");
|
||||
public static final ResourceLocation SPRITE_SHEET = new ResourceLocation(ModInfo.MOD_ID.toLowerCase() + ":" + "textures/gui/slot_sprites.png");
|
||||
|
||||
public TRBuilder() {
|
||||
super(GUI_SHEET);
|
||||
}
|
||||
|
||||
public void drawMultiEnergyBar(GuiScreen gui, int x, int y, int energyStored, int maxEnergyStored, int mouseX, int mouseY) {
|
||||
public void drawMultiEnergyBar(GuiBase gui, int x, int y, int energyStored, int maxEnergyStored, int mouseX, int mouseY) {
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(GUI_SHEET);
|
||||
|
||||
gui.drawTexturedModalRect(x, y, PowerSystem.getDisplayPower().xBar - 15, PowerSystem.getDisplayPower().yBar - 1, 14, 50);
|
||||
|
@ -55,7 +53,39 @@ public class TRBuilder extends GuiBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
public void drawSelectedStack(GuiScreen gui, int x, int y) {
|
||||
public void drawBigBlueBar(GuiBase gui, int x, int y, int value, int max, int mouseX, int mouseY, String suffix) {
|
||||
gui.mc.getTextureManager().bindTexture(GUI_SHEET);
|
||||
if (!suffix.equals("")) {
|
||||
suffix = " " + suffix;
|
||||
}
|
||||
gui.drawTexturedModalRect(x, y, 0, 218, 114, 18);
|
||||
int j = (int) ((double) value / (double) max * 106);
|
||||
if (j < 0)
|
||||
j = 0;
|
||||
gui.drawTexturedModalRect(x + 4, y + 4, 0, 236, j, 10);
|
||||
gui.drawCentredString(value + suffix, y + 5, 0xFFFFFF);
|
||||
if (isInRect(x, y, 114, 18, mouseX, mouseY)) {
|
||||
int percentage = percentage(max, value);
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add("" + TextFormatting.GOLD + value + "/" + max + suffix);
|
||||
list.add(getPercentageColour(percentage) + "" + percentage + "%" + TextFormatting.GRAY + " Full");
|
||||
|
||||
if (value > max) {
|
||||
list.add(TextFormatting.GRAY + "Yo this is storing more than it should be able to");
|
||||
list.add(TextFormatting.GRAY + "prolly a bug");
|
||||
list.add(TextFormatting.GRAY + "pls report and tell how tf you did this");
|
||||
}
|
||||
net.minecraftforge.fml.client.config.GuiUtils.drawHoveringText(list, mouseX, mouseY, gui.width, gui.height, -1, gui.mc.fontRendererObj);
|
||||
GlStateManager.disableLighting();
|
||||
GlStateManager.color(1, 1, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public void drawBigBlueBar(GuiBase gui, int x, int y, int value, int max, int mouseX, int mouseY) {
|
||||
drawBigBlueBar(gui, x, y, value, max, mouseX, mouseY, "");
|
||||
}
|
||||
|
||||
public void drawSelectedStack(GuiBase gui, int x, int y) {
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(GUI_SHEET);
|
||||
gui.drawTexturedModalRect(x - 4, y - 4, 202, 44, 24, 24);
|
||||
}
|
||||
|
|
|
@ -9,9 +9,7 @@ import net.minecraft.util.EnumFacing;
|
|||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.wrapper.InvWrapper;
|
||||
|
||||
import powercrystals.minefactoryreloaded.api.IDeepStorageUnit;
|
||||
|
||||
import reborncore.api.IListInfoProvider;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.IWrenchable;
|
||||
|
@ -23,14 +21,12 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
public class TileTechStorageBase extends TileLegacyMachineBase
|
||||
implements IInventoryProvider, IWrenchable, IListInfoProvider, IDeepStorageUnit {
|
||||
|
||||
public InvWrapper invWrapper;
|
||||
|
||||
public ItemStack storedItem;
|
||||
implements IInventoryProvider, IWrenchable, IListInfoProvider, IDeepStorageUnit {
|
||||
|
||||
public final int maxCapacity;
|
||||
public final Inventory inventory;
|
||||
public InvWrapper invWrapper;
|
||||
public ItemStack storedItem;
|
||||
|
||||
public TileTechStorageBase(String name, int maxCapacity) {
|
||||
this.maxCapacity = maxCapacity;
|
||||
|
@ -43,7 +39,7 @@ public class TileTechStorageBase extends TileLegacyMachineBase
|
|||
if (!world.isRemote) {
|
||||
if (this.getStackInSlot(0) != ItemStack.EMPTY) {
|
||||
if (this.getStoredItemType().isEmpty() || (this.storedItem.isEmpty()
|
||||
&& ItemUtils.isItemEqual(this.getStackInSlot(0), this.getStackInSlot(1), true, true))) {
|
||||
&& ItemUtils.isItemEqual(this.getStackInSlot(0), this.getStackInSlot(1), true, true))) {
|
||||
|
||||
this.storedItem = this.getStackInSlot(0);
|
||||
this.setInventorySlotContents(0, ItemStack.EMPTY);
|
||||
|
@ -70,10 +66,10 @@ public class TileTechStorageBase extends TileLegacyMachineBase
|
|||
this.setInventorySlotContents(1, delivered);
|
||||
this.syncWithAll();
|
||||
} else if (ItemUtils.isItemEqual(this.storedItem, this.getStackInSlot(1), true, true)
|
||||
&& this.getStackInSlot(1).getCount() < this.getStackInSlot(1).getMaxStackSize()) {
|
||||
&& this.getStackInSlot(1).getCount() < this.getStackInSlot(1).getMaxStackSize()) {
|
||||
|
||||
int wanted = Math.min(this.storedItem.getCount(),
|
||||
this.getStackInSlot(1).getMaxStackSize() - this.getStackInSlot(1).getCount());
|
||||
this.getStackInSlot(1).getMaxStackSize() - this.getStackInSlot(1).getCount());
|
||||
|
||||
this.getStackInSlot(1).setCount(this.getStackInSlot(1).getCount() + wanted);
|
||||
this.storedItem.shrink(wanted);
|
||||
|
@ -85,7 +81,7 @@ public class TileTechStorageBase extends TileLegacyMachineBase
|
|||
}
|
||||
|
||||
if (this.getStackInSlot(2) == ItemStack.EMPTY
|
||||
&& (!this.storedItem.isEmpty() || !this.getStackInSlot(1).isEmpty())) {
|
||||
&& (!this.storedItem.isEmpty() || !this.getStackInSlot(1).isEmpty())) {
|
||||
|
||||
ItemStack fake = storedItem.isEmpty() ? this.getStackInSlot(1).copy() : storedItem.copy();
|
||||
fake.setCount(1);
|
||||
|
@ -104,7 +100,7 @@ public class TileTechStorageBase extends TileLegacyMachineBase
|
|||
@Override
|
||||
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) {
|
||||
world.markBlockRangeForRenderUpdate(getPos().getX(), getPos().getY(), getPos().getZ(), getPos().getX(),
|
||||
getPos().getY(), getPos().getZ());
|
||||
getPos().getY(), getPos().getZ());
|
||||
readFromNBT(packet.getNbtCompound());
|
||||
}
|
||||
|
||||
|
@ -259,7 +255,8 @@ public class TileTechStorageBase extends TileLegacyMachineBase
|
|||
|
||||
@Override
|
||||
public boolean hasCapability(final net.minecraftforge.common.capabilities.Capability<?> capability,
|
||||
@javax.annotation.Nullable final net.minecraft.util.EnumFacing facing) {
|
||||
@javax.annotation.Nullable
|
||||
final net.minecraft.util.EnumFacing facing) {
|
||||
return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
|
||||
}
|
||||
|
||||
|
|
Before Width: | Height: | Size: 9 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 239 B |
After Width: | Height: | Size: 242 B |
After Width: | Height: | Size: 258 B |
After Width: | Height: | Size: 226 B |
After Width: | Height: | Size: 249 B |
After Width: | Height: | Size: 368 B |
After Width: | Height: | Size: 310 B |