diff options
Diffstat (limited to 'src/testMod/java/io/github/cottonmc/test/GuiBlock.java')
-rw-r--r-- | src/testMod/java/io/github/cottonmc/test/GuiBlock.java | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/testMod/java/io/github/cottonmc/test/GuiBlock.java b/src/testMod/java/io/github/cottonmc/test/GuiBlock.java new file mode 100644 index 0000000..1b1666f --- /dev/null +++ b/src/testMod/java/io/github/cottonmc/test/GuiBlock.java @@ -0,0 +1,37 @@ +package io.github.cottonmc.test; + +import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; +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.World; + +public class GuiBlock extends BlockWithEntity { + + public GuiBlock() { + super(FabricBlockSettings.copy(Blocks.IRON_BLOCK)); + } + + @Override + public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hitResult) { + player.openHandledScreen(state.createScreenHandlerFactory(world, pos)); + return ActionResult.SUCCESS; + } + + @Override + public BlockEntity createBlockEntity(BlockPos pos, BlockState state) { + return new GuiBlockEntity(pos, state); + } + + @Override + public BlockRenderType getRenderType(BlockState state) { + return BlockRenderType.MODEL; + } +} |