diff options
author | Linnea Gräf <nea@nea.moe> | 2024-11-20 18:51:13 +0100 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-11-20 18:51:13 +0100 |
commit | 14f272f5db13d56de538b71df79f2dccbec0475f (patch) | |
tree | e27491c39e8363ebacdf48f80fff94167d125a33 /src/main/java/moe/nea/funnyteleporters/ColouredChestBlock.java | |
parent | 241682c95b56f47cbd09f79dd77c6ad8ee4489c5 (diff) | |
download | funny-teleporters-14f272f5db13d56de538b71df79f2dccbec0475f.tar.gz funny-teleporters-14f272f5db13d56de538b71df79f2dccbec0475f.tar.bz2 funny-teleporters-14f272f5db13d56de538b71df79f2dccbec0475f.zip |
Add inventory
Diffstat (limited to 'src/main/java/moe/nea/funnyteleporters/ColouredChestBlock.java')
-rw-r--r-- | src/main/java/moe/nea/funnyteleporters/ColouredChestBlock.java | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/main/java/moe/nea/funnyteleporters/ColouredChestBlock.java b/src/main/java/moe/nea/funnyteleporters/ColouredChestBlock.java index eb68f95..cf756e0 100644 --- a/src/main/java/moe/nea/funnyteleporters/ColouredChestBlock.java +++ b/src/main/java/moe/nea/funnyteleporters/ColouredChestBlock.java @@ -2,15 +2,11 @@ package moe.nea.funnyteleporters; import com.mojang.serialization.MapCodec; import eu.pb4.polymer.core.api.block.PolymerBlock; -import net.minecraft.block.AbstractBlock; import net.minecraft.block.AbstractChestBlock; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; -import net.minecraft.block.ChestBlock; import net.minecraft.block.DoubleBlockProperties; -import net.minecraft.block.EnderChestBlock; -import net.minecraft.block.FacingBlock; import net.minecraft.block.HorizontalFacingBlock; import net.minecraft.block.Waterloggable; import net.minecraft.block.entity.BlockEntity; @@ -20,10 +16,10 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.fluid.FluidState; import net.minecraft.fluid.Fluids; import net.minecraft.item.ItemPlacementContext; +import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.state.StateManager; import net.minecraft.state.property.Properties; import net.minecraft.state.property.Property; -import net.minecraft.text.Text; import net.minecraft.util.ActionResult; import net.minecraft.util.BlockMirror; import net.minecraft.util.BlockRotation; @@ -33,6 +29,8 @@ import net.minecraft.util.math.Direction; import net.minecraft.world.World; import net.minecraft.world.WorldAccess; +import java.util.Objects; + public class ColouredChestBlock extends AbstractChestBlock<ColouredChestBlockEntity> implements PolymerBlock, Waterloggable { static Property<Direction> FACING = HorizontalFacingBlock.FACING; static Property<Boolean> WATERLOGGED = Properties.WATERLOGGED; @@ -62,9 +60,10 @@ public class ColouredChestBlock extends AbstractChestBlock<ColouredChestBlockEnt @Override protected ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, BlockHitResult hit) { - // TODO: create a ui or something to configure frequency - player.sendMessage(Text.literal("Ender Chest geöffnet" + player)); - return super.onUse(state, world, pos, player, hit); + if (player instanceof ServerPlayerEntity serverPlayer) { + ((ColouredChestBlockEntity) Objects.requireNonNull(world.getBlockEntity(pos))).openScreen(serverPlayer); + } + return ActionResult.SUCCESS_NO_ITEM_USED; } @Override |