some things

This commit is contained in:
ProfessorProspector 2017-01-07 00:02:57 -08:00
parent 9f74feabff
commit 0f172ddf52
17 changed files with 89 additions and 44 deletions

View file

@ -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

View file

@ -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);
}
}

View file

@ -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;
}
}
}

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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);
}
}

View file

@ -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);
}