diff options
Diffstat (limited to 'GuiTest/src')
6 files changed, 16 insertions, 16 deletions
diff --git a/GuiTest/src/main/java/io/github/cottonmc/test/GuiBlock.java b/GuiTest/src/main/java/io/github/cottonmc/test/GuiBlock.java index 69a0640..96ac123 100644 --- a/GuiTest/src/main/java/io/github/cottonmc/test/GuiBlock.java +++ b/GuiTest/src/main/java/io/github/cottonmc/test/GuiBlock.java @@ -8,7 +8,6 @@ import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.BlockView; import net.minecraft.world.World; public class GuiBlock extends BlockWithEntity { @@ -24,8 +23,8 @@ public class GuiBlock extends BlockWithEntity { } @Override - public BlockEntity createBlockEntity(BlockView var1) { - return new GuiBlockEntity(); + public BlockEntity createBlockEntity(BlockPos pos, BlockState state) { + return new GuiBlockEntity(pos, state); } @Override 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 6a9f741..ddbbe0a 100644 --- a/GuiTest/src/main/java/io/github/cottonmc/test/GuiBlockEntity.java +++ b/GuiTest/src/main/java/io/github/cottonmc/test/GuiBlockEntity.java @@ -1,5 +1,6 @@ package io.github.cottonmc.test; +import net.minecraft.block.BlockState; import net.minecraft.block.entity.BlockEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; @@ -10,16 +11,17 @@ import net.minecraft.screen.ScreenHandlerContext; import net.minecraft.text.LiteralText; import net.minecraft.text.Text; import net.minecraft.util.collection.DefaultedList; +import net.minecraft.util.math.BlockPos; -import javax.annotation.Nullable; +import org.jetbrains.annotations.Nullable; public class GuiBlockEntity extends BlockEntity implements ImplementedInventory, NamedScreenHandlerFactory { static final int INVENTORY_SIZE = 8; DefaultedList<ItemStack> items = DefaultedList.ofSize(INVENTORY_SIZE, ItemStack.EMPTY); - public GuiBlockEntity() { - super(LibGuiTest.GUI_BLOCKENTITY_TYPE); + public GuiBlockEntity(BlockPos pos, BlockState state) { + super(LibGuiTest.GUI_BLOCKENTITY_TYPE, pos, state); } @Override 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 8b567b7..17bfdaa 100644 --- a/GuiTest/src/main/java/io/github/cottonmc/test/LibGuiTest.java +++ b/GuiTest/src/main/java/io/github/cottonmc/test/LibGuiTest.java @@ -6,6 +6,7 @@ import java.nio.file.Path; import java.util.Optional; import net.fabricmc.api.ModInitializer; +import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder; import net.fabricmc.fabric.api.screenhandler.v1.ScreenHandlerRegistry; import net.fabricmc.loader.api.FabricLoader; import net.fabricmc.loader.api.ModContainer; @@ -35,7 +36,7 @@ public class LibGuiTest implements ModInitializer { Registry.register(Registry.BLOCK, new Identifier(MODID, "gui"), GUI_BLOCK); GUI_BLOCK_ITEM = new BlockItem(GUI_BLOCK, new Item.Settings().group(ItemGroup.MISC)); Registry.register(Registry.ITEM, new Identifier(MODID, "gui"), GUI_BLOCK_ITEM); - GUI_BLOCKENTITY_TYPE = BlockEntityType.Builder.create(GuiBlockEntity::new, GUI_BLOCK).build(null); + GUI_BLOCKENTITY_TYPE = FabricBlockEntityTypeBuilder.create(GuiBlockEntity::new, GUI_BLOCK).build(null); Registry.register(Registry.BLOCK_ENTITY_TYPE, new Identifier(MODID, "gui"), GUI_BLOCKENTITY_TYPE); GUI_SCREEN_HANDLER_TYPE = ScreenHandlerRegistry.registerSimple(new Identifier(MODID, "gui"), (int syncId, PlayerInventory inventory) -> { 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 65efe75..22a1bb8 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 @@ -16,7 +16,7 @@ public class LibGuiTestClient implements ClientModInitializer { (desc, inventory, title) -> new CottonInventoryScreen<>(desc, inventory.player, title) ); - CottonHud.INSTANCE.add(new WHudTest(), 10, -20, 10, 10); + CottonHud.add(new WHudTest(), 10, -20, 10, 10); } } 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 85ad3cd..de8a06a 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 @@ -7,6 +7,7 @@ import io.github.cottonmc.cotton.gui.widget.TooltipBuilder; import io.github.cottonmc.cotton.gui.widget.WGridPanel; import io.github.cottonmc.cotton.gui.widget.WLabel; import io.github.cottonmc.cotton.gui.widget.WSlider; +import io.github.cottonmc.cotton.gui.widget.WSprite; import io.github.cottonmc.cotton.gui.widget.WTextField; import io.github.cottonmc.cotton.gui.widget.WTiledSprite; import io.github.cottonmc.cotton.gui.widget.WWidget; @@ -19,12 +20,6 @@ import net.minecraft.text.LiteralText; import net.minecraft.util.Identifier; public class TestClientGui extends LightweightGuiDescription { - - @Environment(EnvType.CLIENT) - public static final BackgroundPainter PANEL = (x, y, panel)->{ - ScreenDrawing.drawBeveledPanel(x-1, y-1, panel.getWidth()+2, panel.getHeight()+2); - }; - //private static final Identifier PORTAL1 = new Identifier("libgui-test:portal.png"); //private static final Identifier PORTAL2 = new Identifier("libgui-test:portal2.png"); @@ -36,10 +31,13 @@ public class TestClientGui extends LightweightGuiDescription { WGridPanel root = new WGridPanel(22); this.setRootPanel(root); WLabel title = new WLabel(new LiteralText("Client Test Gui"), WLabel.DEFAULT_TEXT_COLOR) { + private final WWidget tooltipWidget = new WSprite(new Identifier("minecraft", "textures/block/cobblestone.png")); + @Environment(EnvType.CLIENT) @Override public void addTooltip(TooltipBuilder tooltip) { tooltip.add(new LiteralText("Radical!")); + tooltip.add(tooltipWidget); } }; WTiledSprite wood = new WTiledSprite( @@ -146,7 +144,7 @@ public class TestClientGui extends LightweightGuiDescription { @Override public void paint(MatrixStack matrices, int x, int y, int mouseX, int mouseY) { - ScreenDrawing.coloredRect(x, y, this.getWidth(), this.getHeight(), color); + ScreenDrawing.coloredRect(matrices, x, y, this.getWidth(), this.getHeight(), color); } } } diff --git a/GuiTest/src/main/java/io/github/cottonmc/test/client/WHudTest.java b/GuiTest/src/main/java/io/github/cottonmc/test/client/WHudTest.java index 2cc1e4b..41d566d 100644 --- a/GuiTest/src/main/java/io/github/cottonmc/test/client/WHudTest.java +++ b/GuiTest/src/main/java/io/github/cottonmc/test/client/WHudTest.java @@ -16,7 +16,7 @@ public class WHudTest extends WWidget { @Override public void paint(MatrixStack matrices, int x, int y, int mouseX, int mouseY) { - ScreenDrawing.coloredRect(x, y, width, height, 0xFF_00FF00); + ScreenDrawing.coloredRect(matrices, x, y, width, height, 0xFF_00FF00); } @Override |