mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-25 00:18:34 +01:00
This will make Ellpeck happy (Drill no functioning gui)
This commit is contained in:
parent
121c2cbcac
commit
8286cd448a
9 changed files with 133 additions and 14 deletions
|
@ -115,7 +115,7 @@ e2c81adfe240117fa0ce2e3dfcfd04f4e1034153 assets/actuallyadditions/blockstates/wh
|
||||||
3670535838b4c26d01afe7ee4807c53a6cbaba12 assets/actuallyadditions/blockstates/white_wall_block.json
|
3670535838b4c26d01afe7ee4807c53a6cbaba12 assets/actuallyadditions/blockstates/white_wall_block.json
|
||||||
78e89628e3c6e891f2994b2a1794672f69826516 assets/actuallyadditions/blockstates/wood_casing_block.json
|
78e89628e3c6e891f2994b2a1794672f69826516 assets/actuallyadditions/blockstates/wood_casing_block.json
|
||||||
207adf3d139369e983100a6002f6f77d36d40916 assets/actuallyadditions/blockstates/xp_solidifier_block.json
|
207adf3d139369e983100a6002f6f77d36d40916 assets/actuallyadditions/blockstates/xp_solidifier_block.json
|
||||||
df3dba5195138437f46df032562fdca2cf335bfa assets/actuallyadditions/lang/en_us.json
|
26d79bc30c34bb12341888481fcb2eae4c92b6b9 assets/actuallyadditions/lang/en_us.json
|
||||||
8ce3f2af3288773fb581a3668c2cb90b64c9ee2f assets/actuallyadditions/models/block/advanced_item_laser_relay_block.json
|
8ce3f2af3288773fb581a3668c2cb90b64c9ee2f assets/actuallyadditions/models/block/advanced_item_laser_relay_block.json
|
||||||
de74eda6290d47ef2b26961693e537d7b8795a06 assets/actuallyadditions/models/block/atomic_reconstructor_block.json
|
de74eda6290d47ef2b26961693e537d7b8795a06 assets/actuallyadditions/models/block/atomic_reconstructor_block.json
|
||||||
16a76926a07fc8fa10e4a3949d15ad2ca6920bb8 assets/actuallyadditions/models/block/battery_box_block.json
|
16a76926a07fc8fa10e4a3949d15ad2ca6920bb8 assets/actuallyadditions/models/block/battery_box_block.json
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
"actuallyadditions.gui.name.drill": "Drill",
|
||||||
"actuallyadditions.storage.crystal-flux": "%s/%s Crystal Flux",
|
"actuallyadditions.storage.crystal-flux": "%s/%s Crystal Flux",
|
||||||
"actuallyadditions.tooltip.battery.charge-help": "Sneak-right-click to toggle",
|
"actuallyadditions.tooltip.battery.charge-help": "Sneak-right-click to toggle",
|
||||||
"actuallyadditions.tooltip.battery.charging": "Charging other item in inventory",
|
"actuallyadditions.tooltip.battery.charging": "Charging other item in inventory",
|
||||||
|
|
|
@ -2,24 +2,34 @@ package de.ellpeck.actuallyadditions.client.screens;
|
||||||
|
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import de.ellpeck.actuallyadditions.common.container.DrillContainer;
|
import de.ellpeck.actuallyadditions.common.container.DrillContainer;
|
||||||
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
import de.ellpeck.actuallyadditions.common.utilities.ScreenHelper;
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
|
|
||||||
public class DrillScreen extends ContainerScreen<DrillContainer> {
|
public class DrillScreen extends WtfMojangScreen<DrillContainer> {
|
||||||
|
private static final ResourceLocation background = ScreenHelper.getGuiLocation("gui_drill");
|
||||||
|
|
||||||
public DrillScreen(DrillContainer screenContainer, PlayerInventory inv, ITextComponent titleIn) {
|
public DrillScreen(DrillContainer screenContainer, PlayerInventory inv, ITextComponent titleIn) {
|
||||||
super(screenContainer, inv, titleIn);
|
super(screenContainer, inv, titleIn);
|
||||||
|
|
||||||
|
this.xSize = 176;
|
||||||
|
this.ySize = 54 + 86;
|
||||||
|
|
||||||
|
this.titleY += 90;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void drawGuiContainerBackgroundLayer(MatrixStack matrixStack, float partialTicks, int x, int y) {
|
protected void drawGuiContainerBackgroundLayer(MatrixStack matrixStack, float partialTicks, int x, int y) {
|
||||||
|
getMinecraft().getTextureManager().bindTexture(ScreenHelper.INVENTORY_GUI);
|
||||||
|
blit(matrixStack, this.guiLeft, this.guiTop + 54, 0, 0, 176, 86);
|
||||||
|
|
||||||
|
getMinecraft().getTextureManager().bindTexture(background);
|
||||||
|
blit(matrixStack, this.guiLeft, this.guiTop, 0, 0, 176, 54);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
|
public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
|
||||||
super.render(matrixStack, mouseX, mouseY, partialTicks);
|
super.render(matrixStack, mouseX, mouseY, partialTicks);
|
||||||
|
|
||||||
this.renderBackground(matrixStack);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
package de.ellpeck.actuallyadditions.client.screens;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
|
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
||||||
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
|
import net.minecraft.inventory.container.Container;
|
||||||
|
import net.minecraft.util.text.ITextComponent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inherited name from the original source code! :D
|
||||||
|
*
|
||||||
|
* Wraps up the render logic to display the background & hovered tooltips
|
||||||
|
*/
|
||||||
|
public abstract class WtfMojangScreen<T extends Container> extends ContainerScreen<T> {
|
||||||
|
public WtfMojangScreen(T screenContainer, PlayerInventory inv, ITextComponent titleIn) {
|
||||||
|
super(screenContainer, inv, titleIn);
|
||||||
|
|
||||||
|
this.titleX = 0;
|
||||||
|
this.titleY = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void drawGuiContainerForegroundLayer(MatrixStack matrixStack, int x, int y) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
|
||||||
|
renderBackground(matrixStack);
|
||||||
|
font.drawString(matrixStack, this.title.getString(), ((width - font.getStringWidth(this.title.getString())) / 2f) - this.titleX, (height / 2f) - this.titleY, 0xFFFFFF);
|
||||||
|
super.render(matrixStack, mouseX, mouseY, partialTicks);
|
||||||
|
renderHoveredTooltip(matrixStack, mouseX, mouseY);
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,19 +3,15 @@ package de.ellpeck.actuallyadditions.common.container;
|
||||||
import de.ellpeck.actuallyadditions.common.items.useables.DrillItem;
|
import de.ellpeck.actuallyadditions.common.items.useables.DrillItem;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
import net.minecraft.inventory.container.Container;
|
|
||||||
import net.minecraft.network.PacketBuffer;
|
import net.minecraft.network.PacketBuffer;
|
||||||
|
|
||||||
public class DrillContainer extends Container {
|
public class DrillContainer extends InventoryContainer {
|
||||||
private PlayerInventory inv;
|
|
||||||
|
|
||||||
public DrillContainer(int windowId, PlayerInventory inv, PacketBuffer data) {
|
public DrillContainer(int windowId, PlayerInventory inv, PacketBuffer data) {
|
||||||
this(windowId, inv);
|
super(windowId, inv, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DrillContainer(int windowId, PlayerInventory inv) {
|
public DrillContainer(int windowId, PlayerInventory inv) {
|
||||||
super(ActuallyContainers.DRILL_CONTAINER.get(), windowId);
|
super(windowId, inv);
|
||||||
this.inv = inv;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -23,4 +19,19 @@ public class DrillContainer extends Container {
|
||||||
// Close if the player is not holding the item
|
// Close if the player is not holding the item
|
||||||
return playerIn.getHeldItemMainhand().getItem() instanceof DrillItem;
|
return playerIn.getHeldItemMainhand().getItem() instanceof DrillItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addContainerSlots(int index) {
|
||||||
|
// addSlot(new Slot());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getSlotX() {
|
||||||
|
return DEFAULT_SLOTS_X;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getSlotY() {
|
||||||
|
return 116;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
package de.ellpeck.actuallyadditions.common.container;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
|
import net.minecraft.inventory.container.Container;
|
||||||
|
import net.minecraft.network.PacketBuffer;
|
||||||
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
import net.minecraftforge.items.SlotItemHandler;
|
||||||
|
import net.minecraftforge.items.wrapper.InvWrapper;
|
||||||
|
|
||||||
|
public abstract class InventoryContainer extends Container {
|
||||||
|
public static final int DEFAULT_SLOTS_X = 8;
|
||||||
|
|
||||||
|
protected final IItemHandler playerInventory;
|
||||||
|
|
||||||
|
public InventoryContainer(int windowId, PlayerInventory inv, PacketBuffer data) {
|
||||||
|
this(windowId, inv);
|
||||||
|
}
|
||||||
|
|
||||||
|
public InventoryContainer(int windowId, PlayerInventory inv) {
|
||||||
|
super(ActuallyContainers.DRILL_CONTAINER.get(), windowId);
|
||||||
|
this.playerInventory = new InvWrapper(inv);
|
||||||
|
|
||||||
|
this.setupInventory();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupInventory() {
|
||||||
|
int index = 0, x = getSlotX(), y = getSlotY();
|
||||||
|
|
||||||
|
// Build the players inventory first, building from bottom to top, right to left. The (i>0) magic handles the
|
||||||
|
// space between the hotbar inventory and the players remaining inventory.
|
||||||
|
for (int i = 0; i < 4; i++) {
|
||||||
|
boolean isHotbar = i < 1;
|
||||||
|
for (int j = 0; j < 9; j++) {
|
||||||
|
addSlot(new SlotItemHandler(playerInventory, index, x + (j * 18), isHotbar ? y : ((y - 76) + (i * 18))));
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.addContainerSlots(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will always carry on the index after setting up the players inventory
|
||||||
|
*/
|
||||||
|
protected abstract void addContainerSlots(int index);
|
||||||
|
|
||||||
|
protected abstract int getSlotX();
|
||||||
|
protected abstract int getSlotY();
|
||||||
|
}
|
|
@ -3,13 +3,13 @@ package de.ellpeck.actuallyadditions.common.items.useables;
|
||||||
import de.ellpeck.actuallyadditions.common.config.Config;
|
import de.ellpeck.actuallyadditions.common.config.Config;
|
||||||
import de.ellpeck.actuallyadditions.common.container.DrillContainer;
|
import de.ellpeck.actuallyadditions.common.container.DrillContainer;
|
||||||
import de.ellpeck.actuallyadditions.common.items.CrystalFluxItem;
|
import de.ellpeck.actuallyadditions.common.items.CrystalFluxItem;
|
||||||
|
import de.ellpeck.actuallyadditions.common.utilities.Help;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||||
import net.minecraft.inventory.container.SimpleNamedContainerProvider;
|
import net.minecraft.inventory.container.SimpleNamedContainerProvider;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.ActionResult;
|
import net.minecraft.util.ActionResult;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.text.StringTextComponent;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.ToolType;
|
import net.minecraftforge.common.ToolType;
|
||||||
import net.minecraftforge.fml.network.NetworkHooks;
|
import net.minecraftforge.fml.network.NetworkHooks;
|
||||||
|
@ -32,7 +32,7 @@ public class DrillItem extends CrystalFluxItem {
|
||||||
if (player.isSneaking() && !worldIn.isRemote && handIn == Hand.MAIN_HAND) {
|
if (player.isSneaking() && !worldIn.isRemote && handIn == Hand.MAIN_HAND) {
|
||||||
NetworkHooks.openGui((ServerPlayerEntity) player, new SimpleNamedContainerProvider(
|
NetworkHooks.openGui((ServerPlayerEntity) player, new SimpleNamedContainerProvider(
|
||||||
(windowId, playerInv, playerEntity) -> new DrillContainer(windowId, playerInv),
|
(windowId, playerInv, playerEntity) -> new DrillContainer(windowId, playerInv),
|
||||||
StringTextComponent.EMPTY
|
Help.trans("gui.name.drill")
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
package de.ellpeck.actuallyadditions.common.utilities;
|
||||||
|
|
||||||
|
import de.ellpeck.actuallyadditions.common.ActuallyAdditions;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
|
public final class ScreenHelper {
|
||||||
|
public static final ResourceLocation INVENTORY_GUI = getGuiLocation("gui_inventory");
|
||||||
|
|
||||||
|
public static ResourceLocation getGuiLocation(String file) {
|
||||||
|
return new ResourceLocation(ActuallyAdditions.MOD_ID, "textures/gui/" + file + ".png");
|
||||||
|
}
|
||||||
|
}
|
|
@ -327,6 +327,9 @@ public class GeneratorLanguage extends LanguageProvider {
|
||||||
addPrefixed("tooltip.battery.charging", "Charging other item in inventory");
|
addPrefixed("tooltip.battery.charging", "Charging other item in inventory");
|
||||||
addPrefixed("tooltip.battery.charge-help", "Sneak-right-click to toggle");
|
addPrefixed("tooltip.battery.charge-help", "Sneak-right-click to toggle");
|
||||||
|
|
||||||
|
// Screen names
|
||||||
|
addPrefixed("gui.name.drill", "Drill");
|
||||||
|
|
||||||
// Storage
|
// Storage
|
||||||
addPrefixed("storage.crystal-flux", "%s/%s Crystal Flux");
|
addPrefixed("storage.crystal-flux", "%s/%s Crystal Flux");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue