aboutsummaryrefslogtreecommitdiff
path: root/GuiTest/src/main/java/io
diff options
context:
space:
mode:
authorJuuxel <6596629+Juuxel@users.noreply.github.com>2021-03-19 23:26:53 +0200
committerJuuxel <6596629+Juuxel@users.noreply.github.com>2021-03-19 23:26:53 +0200
commitc321cfc512e7277f934276657ca21b89cae84794 (patch)
tree871a90cc5a70b0b8b0b786527578d69b318a031c /GuiTest/src/main/java/io
parentf3b7ff521a61e4e646621721c02065e30a3c2de8 (diff)
downloadLibGui-c321cfc512e7277f934276657ca21b89cae84794.tar.gz
LibGui-c321cfc512e7277f934276657ca21b89cae84794.tar.bz2
LibGui-c321cfc512e7277f934276657ca21b89cae84794.zip
21w11a
Co-authored-by: CoolMineman <62723322+coolmineman@users.noreply.github.com> Closes #101.
Diffstat (limited to 'GuiTest/src/main/java/io')
-rw-r--r--GuiTest/src/main/java/io/github/cottonmc/test/GuiBlock.java10
-rw-r--r--GuiTest/src/main/java/io/github/cottonmc/test/GuiBlockEntity.java6
-rw-r--r--GuiTest/src/main/java/io/github/cottonmc/test/ImplementedInventory.java5
-rw-r--r--GuiTest/src/main/java/io/github/cottonmc/test/LibGuiTest.java3
-rw-r--r--GuiTest/src/main/java/io/github/cottonmc/test/client/ScrollingTestGui.java8
5 files changed, 20 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..1b1666f 100644
--- a/GuiTest/src/main/java/io/github/cottonmc/test/GuiBlock.java
+++ b/GuiTest/src/main/java/io/github/cottonmc/test/GuiBlock.java
@@ -1,14 +1,16 @@
package io.github.cottonmc.test;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
-import net.minecraft.block.*;
+import net.minecraft.block.BlockRenderType;
+import net.minecraft.block.BlockState;
+import net.minecraft.block.BlockWithEntity;
+import net.minecraft.block.Blocks;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.player.PlayerEntity;
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 +26,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/ImplementedInventory.java b/GuiTest/src/main/java/io/github/cottonmc/test/ImplementedInventory.java
index 1335b64..d8ba3f3 100644
--- a/GuiTest/src/main/java/io/github/cottonmc/test/ImplementedInventory.java
+++ b/GuiTest/src/main/java/io/github/cottonmc/test/ImplementedInventory.java
@@ -5,7 +5,6 @@ import net.minecraft.inventory.Inventories;
import net.minecraft.inventory.Inventory;
import net.minecraft.inventory.SidedInventory;
import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.math.Direction;
@@ -15,7 +14,7 @@ import java.util.List;
* A simple {@code SidedInventory} implementation with only default methods + an item list getter.
*
* <h2>Reading and writing to tags</h2>
- * Use {@link Inventories#fromTag(CompoundTag, DefaultedList)} and {@link Inventories#toTag(CompoundTag, DefaultedList)}
+ * Use {@link Inventories#readNbt(net.minecraft.nbt.NbtCompound, DefaultedList)} and {@link Inventories#writeNbt(net.minecraft.nbt.NbtCompound, DefaultedList)}
* on {@linkplain #getItems() the item list}.
*
* License: <a href="https://creativecommons.org/publicdomain/zero/1.0/">CC0</a>
@@ -210,4 +209,4 @@ public interface ImplementedInventory extends SidedInventory {
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 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/ScrollingTestGui.java b/GuiTest/src/main/java/io/github/cottonmc/test/client/ScrollingTestGui.java
index 1ae78b6..30bda75 100644
--- a/GuiTest/src/main/java/io/github/cottonmc/test/client/ScrollingTestGui.java
+++ b/GuiTest/src/main/java/io/github/cottonmc/test/client/ScrollingTestGui.java
@@ -1,14 +1,16 @@
package io.github.cottonmc.test.client;
-import io.github.cottonmc.cotton.gui.widget.WLabeledSlider;
-
+import net.minecraft.item.Items;
import net.minecraft.text.LiteralText;
import io.github.cottonmc.cotton.gui.client.LightweightGuiDescription;
import io.github.cottonmc.cotton.gui.widget.WBox;
+import io.github.cottonmc.cotton.gui.widget.WButton;
import io.github.cottonmc.cotton.gui.widget.WGridPanel;
+import io.github.cottonmc.cotton.gui.widget.WLabeledSlider;
import io.github.cottonmc.cotton.gui.widget.WScrollPanel;
import io.github.cottonmc.cotton.gui.widget.data.Axis;
+import io.github.cottonmc.cotton.gui.widget.icon.ItemIcon;
public class ScrollingTestGui extends LightweightGuiDescription {
public ScrollingTestGui() {
@@ -19,6 +21,8 @@ public class ScrollingTestGui extends LightweightGuiDescription {
box.add(new WLabeledSlider(0, 10, new LiteralText("Slider #" + i)));
}
+ box.add(new WButton(new ItemIcon(Items.APPLE)));
+
root.add(new WScrollPanel(box), 0, 0, 5, 3);
root.validate(this);
}