diff options
Diffstat (limited to 'src/main')
7 files changed, 25 insertions, 28 deletions
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/CottonCraftingController.java b/src/main/java/io/github/cottonmc/cotton/gui/CottonCraftingController.java index 54038ec..ec0cdc9 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/CottonCraftingController.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/CottonCraftingController.java @@ -13,12 +13,6 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.InventoryProvider; import net.minecraft.block.entity.BlockEntity; -import net.minecraft.container.ArrayPropertyDelegate; -import net.minecraft.container.BlockContext; -import net.minecraft.container.CraftingContainer; -import net.minecraft.container.PropertyDelegate; -import net.minecraft.container.Slot; -import net.minecraft.container.SlotActionType; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.Inventory; @@ -27,9 +21,12 @@ import net.minecraft.recipe.Recipe; import net.minecraft.recipe.RecipeFinder; import net.minecraft.recipe.RecipeInputProvider; import net.minecraft.recipe.RecipeType; +import net.minecraft.screen.*; +import net.minecraft.screen.slot.Slot; +import net.minecraft.screen.slot.SlotActionType; import net.minecraft.world.World; -public class CottonCraftingController extends CraftingContainer<Inventory> implements GuiDescription { +public class CottonCraftingController extends AbstractRecipeScreenHandler<Inventory> implements GuiDescription { protected Inventory blockInventory; protected PlayerInventory playerInventory; @@ -337,7 +334,7 @@ public class CottonCraftingController extends CraftingContainer<Inventory> imple return new WPlayerInvPanel(this.playerInventory); } - public static Inventory getBlockInventory(BlockContext ctx) { + public static Inventory getBlockInventory(ScreenHandlerContext ctx) { return ctx.run((world, pos) -> { BlockState state = world.getBlockState(pos); Block b = state.getBlock(); @@ -359,7 +356,7 @@ public class CottonCraftingController extends CraftingContainer<Inventory> imple }).orElse(EmptyInventory.INSTANCE); } - public static PropertyDelegate getBlockPropertyDelegate(BlockContext ctx) { + public static PropertyDelegate getBlockPropertyDelegate(ScreenHandlerContext ctx) { return ctx.run((world, pos) -> { BlockState state = world.getBlockState(pos); Block block = state.getBlock(); diff --git a/src/main/java/io/github/cottonmc/cotton/gui/GuiDescription.java b/src/main/java/io/github/cottonmc/cotton/gui/GuiDescription.java index c494016..3239179 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/GuiDescription.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/GuiDescription.java @@ -6,7 +6,7 @@ import io.github.cottonmc.cotton.gui.widget.WPanel; import io.github.cottonmc.cotton.gui.widget.WWidget; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.container.PropertyDelegate; +import net.minecraft.screen.PropertyDelegate; public interface GuiDescription { public WPanel getRootPanel(); diff --git a/src/main/java/io/github/cottonmc/cotton/gui/PropertyDelegateHolder.java b/src/main/java/io/github/cottonmc/cotton/gui/PropertyDelegateHolder.java index 6ec1476..5b33320 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/PropertyDelegateHolder.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/PropertyDelegateHolder.java @@ -1,6 +1,6 @@ package io.github.cottonmc.cotton.gui; -import net.minecraft.container.PropertyDelegate; +import net.minecraft.screen.PropertyDelegate; public interface PropertyDelegateHolder { public PropertyDelegate getPropertyDelegate(); diff --git a/src/main/java/io/github/cottonmc/cotton/gui/ValidatedSlot.java b/src/main/java/io/github/cottonmc/cotton/gui/ValidatedSlot.java index 7e116d2..e6b30af 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/ValidatedSlot.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/ValidatedSlot.java @@ -1,9 +1,9 @@ package io.github.cottonmc.cotton.gui; -import net.minecraft.container.Slot; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.inventory.Inventory; import net.minecraft.item.ItemStack; +import net.minecraft.screen.slot.Slot; public class ValidatedSlot extends Slot { private final int slotNumber; diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/CottonInventoryScreen.java b/src/main/java/io/github/cottonmc/cotton/gui/client/CottonInventoryScreen.java index 9bc0452..83c1837 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/client/CottonInventoryScreen.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/client/CottonInventoryScreen.java @@ -1,5 +1,6 @@ package io.github.cottonmc.cotton.gui.client; +import net.minecraft.client.gui.screen.ingame.HandledScreen; import net.minecraft.client.render.DiffuseLighting; import org.lwjgl.glfw.GLFW; @@ -7,12 +8,11 @@ import io.github.cottonmc.cotton.gui.CottonCraftingController; import io.github.cottonmc.cotton.gui.widget.WPanel; import io.github.cottonmc.cotton.gui.widget.WWidget; import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.screen.ingame.ContainerScreen; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.text.LiteralText; import net.minecraft.text.Text; -public class CottonInventoryScreen<T extends CottonCraftingController> extends ContainerScreen<T> implements TextHoverRendererScreen { +public class CottonInventoryScreen<T extends CottonCraftingController> extends HandledScreen<T> implements TextHoverRendererScreen { protected CottonCraftingController description; public static final int PADDING = 8; protected WWidget lastResponder = null; @@ -23,15 +23,15 @@ public class CottonInventoryScreen<T extends CottonCraftingController> extends C this.description = container; width = 18*9; height = 18*9; - this.containerWidth = 18*9; - this.containerHeight = 18*9; + this.backgroundWidth = 18*9; + this.backgroundHeight = 18*9; } /* * RENDERING NOTES: * * * "width" and "height" are the width and height of the overall screen - * * "containerWidth" and "containerHeight" are the width and height of the panel to render + * * "backgroundWidth" and "backgroundHeight" are the width and height of the panel to render * * ~~"left" and "top" are *actually* self-explanatory~~ * * "left" and "top" are now (1.15) "x" and "y". A bit less self-explanatory, I guess. * * coordinates start at 0,0 at the topleft of the screen. @@ -50,16 +50,16 @@ public class CottonInventoryScreen<T extends CottonCraftingController> extends C WPanel basePanel = description.getRootPanel(); if (basePanel!=null) { basePanel.validate(description); - - containerWidth = basePanel.getWidth(); - containerHeight = basePanel.getHeight(); + + backgroundWidth = basePanel.getWidth(); + backgroundHeight = basePanel.getHeight(); //DEBUG - if (containerWidth<16) containerWidth=300; - if (containerHeight<16) containerHeight=300; + if (backgroundWidth<16) backgroundWidth=300; + if (backgroundHeight<16) backgroundHeight=300; } - x = (width / 2) - (containerWidth / 2); - y = (height / 2) - (containerHeight / 2); + x = (width / 2) - (backgroundWidth / 2); + y = (height / 2) - (backgroundHeight / 2); } @Override @@ -84,13 +84,13 @@ public class CottonInventoryScreen<T extends CottonCraftingController> extends C public boolean keyPressed(int ch, int keyCode, int modifiers) { //System.out.println("Key " + Integer.toHexString(ch)+" "+Integer.toHexString(keyCode)); if (ch==GLFW.GLFW_KEY_ESCAPE) { - this.client.player.closeContainer(); + this.client.player.closeHandledScreen(); return true; } else { //if (super.keyPressed(ch, keyCode, modifiers)) return true; if (description.getFocus()==null) { if (MinecraftClient.getInstance().options.keyInventory.matchesKey(ch, keyCode)) { - this.client.player.closeContainer(); + this.client.player.closeHandledScreen(); return true; } return false; diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/LightweightGuiDescription.java b/src/main/java/io/github/cottonmc/cotton/gui/client/LightweightGuiDescription.java index 6284c2f..7c9c73c 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/client/LightweightGuiDescription.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/client/LightweightGuiDescription.java @@ -8,7 +8,7 @@ import io.github.cottonmc.cotton.gui.widget.WGridPanel; import io.github.cottonmc.cotton.gui.widget.WLabel; import io.github.cottonmc.cotton.gui.widget.WPanel; import io.github.cottonmc.cotton.gui.widget.WWidget; -import net.minecraft.container.PropertyDelegate; +import net.minecraft.screen.PropertyDelegate; /** * A GuiDescription without any associated Minecraft classes diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WBar.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WBar.java index ac6271d..29640d9 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WBar.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WBar.java @@ -6,7 +6,7 @@ import io.github.cottonmc.cotton.gui.GuiDescription; import io.github.cottonmc.cotton.gui.client.ScreenDrawing; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.container.PropertyDelegate; +import net.minecraft.screen.PropertyDelegate; import net.minecraft.text.Text; import net.minecraft.text.TranslatableText; import net.minecraft.util.Identifier; |