diff options
author | Juuxel <6596629+Juuxel@users.noreply.github.com> | 2020-05-08 20:21:55 +0300 |
---|---|---|
committer | Juuxel <6596629+Juuxel@users.noreply.github.com> | 2020-05-08 20:21:55 +0300 |
commit | 6134cc78ea2452e9d133258dfcf5bc634148d576 (patch) | |
tree | d3a98a1976a18f2d2acf27beb461b23ec52fa736 /GuiTest/src/main/java | |
parent | bedf10d477896b186e557064ad59cd96a673daa2 (diff) | |
download | LibGui-6134cc78ea2452e9d133258dfcf5bc634148d576.tar.gz LibGui-6134cc78ea2452e9d133258dfcf5bc634148d576.tar.bz2 LibGui-6134cc78ea2452e9d133258dfcf5bc634148d576.zip |
Update test mod to 20w17a
Diffstat (limited to 'GuiTest/src/main/java')
-rw-r--r-- | GuiTest/src/main/java/io/github/cottonmc/test/GuiBlockEntity.java | 4 | ||||
-rw-r--r-- | GuiTest/src/main/java/io/github/cottonmc/test/ImplementedInventory.java | 32 | ||||
-rw-r--r-- | GuiTest/src/main/java/io/github/cottonmc/test/LibGuiTest.java | 6 | ||||
-rw-r--r-- | GuiTest/src/main/java/io/github/cottonmc/test/TestController.java (renamed from GuiTest/src/main/java/io/github/cottonmc/test/TestContainer.java) | 10 | ||||
-rw-r--r-- | GuiTest/src/main/java/io/github/cottonmc/test/client/LibGuiTestClient.java | 6 | ||||
-rw-r--r-- | GuiTest/src/main/java/io/github/cottonmc/test/client/TestClientGui.java | 10 |
6 files changed, 34 insertions, 34 deletions
diff --git a/GuiTest/src/main/java/io/github/cottonmc/test/GuiBlockEntity.java b/GuiTest/src/main/java/io/github/cottonmc/test/GuiBlockEntity.java index f07ccb7..3e76fdd 100644 --- a/GuiTest/src/main/java/io/github/cottonmc/test/GuiBlockEntity.java +++ b/GuiTest/src/main/java/io/github/cottonmc/test/GuiBlockEntity.java @@ -3,7 +3,7 @@ package io.github.cottonmc.test; import net.minecraft.block.entity.BlockEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.util.DefaultedList; +import net.minecraft.util.collection.DefaultedList; public class GuiBlockEntity extends BlockEntity implements ImplementedInventory { @@ -19,7 +19,7 @@ public class GuiBlockEntity extends BlockEntity implements ImplementedInventory } @Override - public boolean canPlayerUseInv(PlayerEntity player) { + public boolean canPlayerUse(PlayerEntity player) { return pos.isWithinDistance(player.getBlockPos(), 4.5); } diff --git a/GuiTest/src/main/java/io/github/cottonmc/test/ImplementedInventory.java b/GuiTest/src/main/java/io/github/cottonmc/test/ImplementedInventory.java index 177affd..1335b64 100644 --- a/GuiTest/src/main/java/io/github/cottonmc/test/ImplementedInventory.java +++ b/GuiTest/src/main/java/io/github/cottonmc/test/ImplementedInventory.java @@ -6,7 +6,7 @@ import net.minecraft.inventory.Inventory; import net.minecraft.inventory.SidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundTag; -import net.minecraft.util.DefaultedList; +import net.minecraft.util.collection.DefaultedList; import net.minecraft.util.math.Direction; import java.util.List; @@ -64,7 +64,7 @@ public interface ImplementedInventory extends SidedInventory { * @return the available slots */ @Override - default int[] getInvAvailableSlots(Direction side) { + default int[] getAvailableSlots(Direction side) { int[] result = new int[getItems().size()]; for (int i = 0; i < result.length; i++) { result[i] = i; @@ -84,7 +84,7 @@ public interface ImplementedInventory extends SidedInventory { * @return true if the stack can be inserted */ @Override - default boolean canInsertInvStack(int slot, ItemStack stack, Direction side) { + default boolean canInsert(int slot, ItemStack stack, Direction side) { return true; } @@ -99,7 +99,7 @@ public interface ImplementedInventory extends SidedInventory { * @return true if the stack can be extracted */ @Override - default boolean canExtractInvStack(int slot, ItemStack stack, Direction side) { + default boolean canExtract(int slot, ItemStack stack, Direction side) { return true; } @@ -113,7 +113,7 @@ public interface ImplementedInventory extends SidedInventory { * @return the inventory size */ @Override - default int getInvSize() { + default int size() { return getItems().size(); } @@ -121,9 +121,9 @@ public interface ImplementedInventory extends SidedInventory { * @return true if this inventory has only empty stacks, false otherwise */ @Override - default boolean isInvEmpty() { - for (int i = 0; i < getInvSize(); i++) { - ItemStack stack = getInvStack(i); + default boolean isEmpty() { + for (int i = 0; i < size(); i++) { + ItemStack stack = getStack(i); if (!stack.isEmpty()) { return false; } @@ -139,7 +139,7 @@ public interface ImplementedInventory extends SidedInventory { * @return the item in the slot */ @Override - default ItemStack getInvStack(int slot) { + default ItemStack getStack(int slot) { return getItems().get(slot); } @@ -154,7 +154,7 @@ public interface ImplementedInventory extends SidedInventory { * @return a stack */ @Override - default ItemStack takeInvStack(int slot, int count) { + default ItemStack removeStack(int slot, int count) { ItemStack result = Inventories.splitStack(getItems(), slot, count); if (!result.isEmpty()) { markDirty(); @@ -172,24 +172,24 @@ public interface ImplementedInventory extends SidedInventory { * @return the removed stack */ @Override - default ItemStack removeInvStack(int slot) { + default ItemStack removeStack(int slot) { return Inventories.removeStack(getItems(), slot); } /** * Replaces the current stack in the {@code slot} with the provided stack. * - * <p>If the stack is too big for this inventory ({@link Inventory#getInvMaxStackAmount()}), + * <p>If the stack is too big for this inventory ({@link Inventory#getMaxCountPerStack()} ()}), * it gets resized to this inventory's maximum amount. * * @param slot the slot * @param stack the stack */ @Override - default void setInvStack(int slot, ItemStack stack) { + default void setStack(int slot, ItemStack stack) { getItems().set(slot, stack); - if (stack.getCount() > getInvMaxStackAmount()) { - stack.setCount(getInvMaxStackAmount()); + if (stack.getCount() > getMaxCountPerStack()) { + stack.setCount(getMaxCountPerStack()); } } @@ -207,7 +207,7 @@ public interface ImplementedInventory extends SidedInventory { } @Override - default boolean canPlayerUseInv(PlayerEntity player) { + default boolean canPlayerUse(PlayerEntity player) { return true; } }
\ No newline at end of file diff --git a/GuiTest/src/main/java/io/github/cottonmc/test/LibGuiTest.java b/GuiTest/src/main/java/io/github/cottonmc/test/LibGuiTest.java index 32d359d..6d63688 100644 --- a/GuiTest/src/main/java/io/github/cottonmc/test/LibGuiTest.java +++ b/GuiTest/src/main/java/io/github/cottonmc/test/LibGuiTest.java @@ -10,13 +10,13 @@ import net.fabricmc.fabric.api.container.ContainerProviderRegistry; import net.fabricmc.loader.api.FabricLoader; import net.fabricmc.loader.api.ModContainer; import net.minecraft.block.entity.BlockEntityType; -import net.minecraft.container.BlockContext; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.BlockItem; import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; +import net.minecraft.network.PacketByteBuf; +import net.minecraft.screen.ScreenHandlerContext; import net.minecraft.util.Identifier; -import net.minecraft.util.PacketByteBuf; import net.minecraft.util.registry.Registry; public class LibGuiTest implements ModInitializer { @@ -38,7 +38,7 @@ public class LibGuiTest implements ModInitializer { ContainerProviderRegistry.INSTANCE.registerFactory(new Identifier(MODID, "gui"), (int syncId, Identifier identifier, PlayerEntity player, PacketByteBuf buf)->{ - return new TestContainer(syncId, player.inventory, BlockContext.create(player.getEntityWorld(), buf.readBlockPos())); + return new TestController(syncId, player.inventory, ScreenHandlerContext.create(player.getEntityWorld(), buf.readBlockPos())); }); Optional<ModContainer> containerOpt = FabricLoader.getInstance().getModContainer("jankson"); diff --git a/GuiTest/src/main/java/io/github/cottonmc/test/TestContainer.java b/GuiTest/src/main/java/io/github/cottonmc/test/TestController.java index b4bb11b..43a0a6f 100644 --- a/GuiTest/src/main/java/io/github/cottonmc/test/TestContainer.java +++ b/GuiTest/src/main/java/io/github/cottonmc/test/TestController.java @@ -1,18 +1,18 @@ package io.github.cottonmc.test; -import io.github.cottonmc.cotton.gui.CottonCraftingController; +import io.github.cottonmc.cotton.gui.CottonInventoryController; import io.github.cottonmc.cotton.gui.widget.WButton; import io.github.cottonmc.cotton.gui.widget.WGridPanel; import io.github.cottonmc.cotton.gui.widget.WItemSlot; import io.github.cottonmc.cotton.gui.widget.WPlayerInvPanel; -import net.minecraft.container.BlockContext; import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.screen.ScreenHandlerContext; import net.minecraft.text.LiteralText; -public class TestContainer extends CottonCraftingController { +public class TestController extends CottonInventoryController { - public TestContainer(int syncId, PlayerInventory playerInventory, BlockContext context) { - super(null, syncId, playerInventory, getBlockInventory(context), null); + public TestController(int syncId, PlayerInventory playerInventory, ScreenHandlerContext context) { + super(syncId, playerInventory, getBlockInventory(context), null); WGridPanel root = (WGridPanel)this.getRootPanel(); diff --git a/GuiTest/src/main/java/io/github/cottonmc/test/client/LibGuiTestClient.java b/GuiTest/src/main/java/io/github/cottonmc/test/client/LibGuiTestClient.java index 6db6902..a2a23fb 100644 --- a/GuiTest/src/main/java/io/github/cottonmc/test/client/LibGuiTestClient.java +++ b/GuiTest/src/main/java/io/github/cottonmc/test/client/LibGuiTestClient.java @@ -2,17 +2,17 @@ package io.github.cottonmc.test.client; import io.github.cottonmc.cotton.gui.client.CottonInventoryScreen; import io.github.cottonmc.test.LibGuiTest; -import io.github.cottonmc.test.TestContainer; +import io.github.cottonmc.test.TestController; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.fabric.api.client.screen.ScreenProviderRegistry; -import net.minecraft.container.BlockContext; +import net.minecraft.screen.ScreenHandlerContext; import net.minecraft.util.Identifier; public class LibGuiTestClient implements ClientModInitializer { @Override public void onInitializeClient() { - ScreenProviderRegistry.INSTANCE.registerFactory(new Identifier(LibGuiTest.MODID, "gui"), (syncId, identifier, player, buf)->new CottonInventoryScreen<TestContainer>(new TestContainer(syncId, player.inventory, BlockContext.create(player.getEntityWorld(), buf.readBlockPos())), player)); + ScreenProviderRegistry.INSTANCE.registerFactory(new Identifier(LibGuiTest.MODID, "gui"), (syncId, identifier, player, buf)->new CottonInventoryScreen<TestController>(new TestController(syncId, player.inventory, ScreenHandlerContext.create(player.getEntityWorld(), buf.readBlockPos())), player)); } } diff --git a/GuiTest/src/main/java/io/github/cottonmc/test/client/TestClientGui.java b/GuiTest/src/main/java/io/github/cottonmc/test/client/TestClientGui.java index e1e23d5..b96a359 100644 --- a/GuiTest/src/main/java/io/github/cottonmc/test/client/TestClientGui.java +++ b/GuiTest/src/main/java/io/github/cottonmc/test/client/TestClientGui.java @@ -20,7 +20,9 @@ import io.github.cottonmc.cotton.gui.widget.data.Axis; import io.github.cottonmc.cotton.gui.widget.data.Color; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; +import net.minecraft.client.util.math.MatrixStack; import net.minecraft.text.LiteralText; +import net.minecraft.text.Text; import net.minecraft.util.Identifier; public class TestClientGui extends LightweightGuiDescription { @@ -43,8 +45,8 @@ public class TestClientGui extends LightweightGuiDescription { WLabel title = new WLabel(new LiteralText("Client Test Gui"), WLabel.DEFAULT_TEXT_COLOR) { @Override - public void addInformation(List<String> information) { - information.add("Radical!"); + public void addTooltip(List<Text> tooltip) { + tooltip.add(new LiteralText("Radical!")); } }; root.add(title, 0, 0); @@ -142,9 +144,7 @@ public class TestClientGui extends LightweightGuiDescription { } @Override - public void paintBackground(int x, int y, int mouseX, int mouseY) { - super.paintBackground(x, y, mouseX, mouseY); - + public void paint(MatrixStack matrices, int x, int y, int mouseX, int mouseY) { ScreenDrawing.coloredRect(x, y, this.getWidth(), this.getHeight(), color); } } |