diff options
author | Juuxel <6596629+Juuxel@users.noreply.github.com> | 2020-11-26 18:25:29 +0200 |
---|---|---|
committer | Juuxel <6596629+Juuxel@users.noreply.github.com> | 2020-11-26 18:25:29 +0200 |
commit | 50bcec28d59d04b9ec8ceead159df0e7c659491c (patch) | |
tree | db6f7eee1a3d949ee9ae0e15f783d7291df59bc3 /GuiTest/src | |
parent | 272837528c7bf23e7e289d46fb4510d06102cca7 (diff) | |
download | LibGui-50bcec28d59d04b9ec8ceead159df0e7c659491c.tar.gz LibGui-50bcec28d59d04b9ec8ceead159df0e7c659491c.tar.bz2 LibGui-50bcec28d59d04b9ec8ceead159df0e7c659491c.zip |
Fix compilation issues, add support for tooltip components (also from data and widgets)
Diffstat (limited to 'GuiTest/src')
4 files changed, 12 insertions, 12 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..82188d2 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,6 +11,7 @@ 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; @@ -18,8 +20,8 @@ public class GuiBlockEntity extends BlockEntity implements ImplementedInventory, 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/TestClientGui.java b/GuiTest/src/main/java/io/github/cottonmc/test/client/TestClientGui.java index 85ad3cd..52b0e81 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( |