40 lines
1.7 KiB
Java
40 lines
1.7 KiB
Java
package com.thebrokenrail.sorcerycraft.block;
|
|
|
|
import com.thebrokenrail.sorcerycraft.SorceryCraft;
|
|
import net.fabricmc.fabric.api.block.FabricBlockSettings;
|
|
import net.fabricmc.fabric.api.container.ContainerProviderRegistry;
|
|
import net.minecraft.block.Block;
|
|
import net.minecraft.block.BlockState;
|
|
import net.minecraft.block.Material;
|
|
import net.minecraft.container.BlockContext;
|
|
import net.minecraft.container.NameableContainerFactory;
|
|
import net.minecraft.container.SimpleNamedContainerFactory;
|
|
import net.minecraft.entity.player.PlayerEntity;
|
|
import net.minecraft.text.TranslatableText;
|
|
import net.minecraft.util.ActionResult;
|
|
import net.minecraft.util.Hand;
|
|
import net.minecraft.util.Identifier;
|
|
import net.minecraft.util.hit.BlockHitResult;
|
|
import net.minecraft.util.math.BlockPos;
|
|
import net.minecraft.world.World;
|
|
|
|
@SuppressWarnings("deprecation")
|
|
public class CastingTableBlock extends Block {
|
|
public CastingTableBlock() {
|
|
super(FabricBlockSettings.of(Material.STONE).strength(2.0F, 6.0F).build());
|
|
}
|
|
|
|
@Override
|
|
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
|
|
if (!world.isClient()) {
|
|
ContainerProviderRegistry.INSTANCE.openContainer(new Identifier(SorceryCraft.NAMESPACE, "casting_table"), player, (buf) -> buf.writeBlockPos(pos));
|
|
}
|
|
return ActionResult.SUCCESS;
|
|
}
|
|
|
|
@Override
|
|
public NameableContainerFactory createContainerFactory(BlockState state, World world, BlockPos pos) {
|
|
return new SimpleNamedContainerFactory((i, playerInventory, playerEntity) -> new CastingTableContainer(i, playerInventory, BlockContext.create(world, pos)), new TranslatableText("container." + SorceryCraft.NAMESPACE + ".casting_table"));
|
|
}
|
|
}
|