halfhearted work on slates
This commit is contained in:
parent
6392596363
commit
5949674e24
4 changed files with 115 additions and 10 deletions
|
@ -44,8 +44,8 @@ public class BlockConjured extends Block implements SimpleWaterloggedBlock, Enti
|
||||||
@Override
|
@Override
|
||||||
public void stepOn(Level pLevel, @NotNull BlockPos pPos, @NotNull BlockState pState, @NotNull Entity pEntity) {
|
public void stepOn(Level pLevel, @NotNull BlockPos pPos, @NotNull BlockState pState, @NotNull Entity pEntity) {
|
||||||
BlockEntity tile = pLevel.getBlockEntity(pPos);
|
BlockEntity tile = pLevel.getBlockEntity(pPos);
|
||||||
if (tile instanceof BlockEntityConjured) {
|
if (tile instanceof BlockEntityConjured bec) {
|
||||||
((BlockEntityConjured) tile).walkParticle(pEntity);
|
bec.walkParticle(pEntity);
|
||||||
}
|
}
|
||||||
super.stepOn(pLevel, pPos, pState, pEntity);
|
super.stepOn(pLevel, pPos, pState, pEntity);
|
||||||
}
|
}
|
||||||
|
@ -54,8 +54,8 @@ public class BlockConjured extends Block implements SimpleWaterloggedBlock, Enti
|
||||||
public void animateTick(@NotNull BlockState pState, @NotNull Level pLevel, @NotNull BlockPos pPos,
|
public void animateTick(@NotNull BlockState pState, @NotNull Level pLevel, @NotNull BlockPos pPos,
|
||||||
@NotNull Random pRand) {
|
@NotNull Random pRand) {
|
||||||
BlockEntity tile = pLevel.getBlockEntity(pPos);
|
BlockEntity tile = pLevel.getBlockEntity(pPos);
|
||||||
if (tile instanceof BlockEntityConjured) {
|
if (tile instanceof BlockEntityConjured bec) {
|
||||||
((BlockEntityConjured) tile).particleEffect();
|
bec.particleEffect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
package at.petrak.hexcasting.common.blocks;
|
||||||
|
|
||||||
|
import at.petrak.hexcasting.hexmath.HexDir;
|
||||||
|
import at.petrak.hexcasting.hexmath.HexPattern;
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
import net.minecraft.client.renderer.MultiBufferSource;
|
||||||
|
import net.minecraft.client.renderer.block.BlockRenderDispatcher;
|
||||||
|
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
||||||
|
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
public class BlockEntitySlate extends BlockEntity {
|
||||||
|
private static final Random RANDOM = new Random();
|
||||||
|
private HexPattern pattern = new HexPattern(HexDir.EAST, new ArrayList<>());
|
||||||
|
|
||||||
|
public static final String TAG_PATTERN = "pattern";
|
||||||
|
|
||||||
|
public BlockEntitySlate(BlockPos pos, BlockState state) {
|
||||||
|
super(HexBlocks.SLATE_TILE.get(), pos, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Renderer implements BlockEntityRenderer<BlockEntity> {
|
||||||
|
private final BlockRenderDispatcher dispatcher;
|
||||||
|
|
||||||
|
public Renderer(BlockEntityRendererProvider.Context ctx) {
|
||||||
|
this.dispatcher = ctx.getBlockRenderDispatcher();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(BlockEntity maybeTile, float pPartialTick, PoseStack ps,
|
||||||
|
MultiBufferSource buffer, int pPackedLight, int pPackedOverlay) {
|
||||||
|
|
||||||
|
|
||||||
|
if (!(maybeTile instanceof BlockEntitySlate tile)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
package at.petrak.hexcasting.common.blocks;
|
||||||
|
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.core.Direction;
|
||||||
|
import net.minecraft.world.level.BlockGetter;
|
||||||
|
import net.minecraft.world.level.block.Block;
|
||||||
|
import net.minecraft.world.level.block.FaceAttachedHorizontalDirectionalBlock;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import net.minecraft.world.level.block.state.properties.AttachFace;
|
||||||
|
import net.minecraft.world.level.material.PushReaction;
|
||||||
|
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||||
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
|
|
||||||
|
public class BlockSlate extends FaceAttachedHorizontalDirectionalBlock {
|
||||||
|
|
||||||
|
protected static final double THICKNESS = 1;
|
||||||
|
protected static final VoxelShape AABB_FLOOR = Block.box(0, 0, 0, 16, THICKNESS, 16);
|
||||||
|
protected static final VoxelShape AABB_CEILING = Block.box(0, 16 - THICKNESS, 0, 16, 16, 16);
|
||||||
|
protected static final VoxelShape AABB_EAST_WALL = Block.box(0, 0, 0, THICKNESS, 16, 16);
|
||||||
|
protected static final VoxelShape AABB_WEST_WALL = Block.box(0, 16 - THICKNESS, 0, 16, 16, 16);
|
||||||
|
protected static final VoxelShape AABB_SOUTH_WALL = Block.box(0, 0, 0, 16, 16, THICKNESS);
|
||||||
|
protected static final VoxelShape AABB_NORTH_WALL = Block.box(0, 0, 16 - THICKNESS, 16, 16, 16);
|
||||||
|
|
||||||
|
public BlockSlate(Properties p_53182_) {
|
||||||
|
super(p_53182_);
|
||||||
|
this.registerDefaultState(
|
||||||
|
this.getStateDefinition().any().setValue(FACING, Direction.NORTH).setValue(FACE, AttachFace.WALL));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VoxelShape getShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) {
|
||||||
|
return switch (pState.getValue(FACE)) {
|
||||||
|
case FLOOR -> AABB_FLOOR;
|
||||||
|
case CEILING -> AABB_CEILING;
|
||||||
|
case WALL -> switch (pState.getValue(FACING)) {
|
||||||
|
case EAST -> AABB_EAST_WALL;
|
||||||
|
case WEST -> AABB_WEST_WALL;
|
||||||
|
case SOUTH -> AABB_SOUTH_WALL;
|
||||||
|
// North case. I need to cover up and down, but presumably those
|
||||||
|
// states are illegal?
|
||||||
|
default -> AABB_NORTH_WALL;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PushReaction getPistonPushReaction(BlockState pState) {
|
||||||
|
return PushReaction.DESTROY;
|
||||||
|
}
|
||||||
|
}
|
|
@ -18,21 +18,32 @@ import static at.petrak.hexcasting.common.items.HexItems.TAB;
|
||||||
|
|
||||||
public class HexBlocks {
|
public class HexBlocks {
|
||||||
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, HexMod.MOD_ID);
|
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, HexMod.MOD_ID);
|
||||||
public static final DeferredRegister<BlockEntityType<?>> BLOCK_ENTITIES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITIES, HexMod.MOD_ID);
|
public static final DeferredRegister<BlockEntityType<?>> BLOCK_ENTITIES = DeferredRegister.create(
|
||||||
|
ForgeRegistries.BLOCK_ENTITIES, HexMod.MOD_ID);
|
||||||
|
|
||||||
public static final RegistryObject<Block> CONJURED = registerBlock("conjured",
|
public static final RegistryObject<Block> CONJURED = registerBlock("conjured",
|
||||||
new BlockConjured(BlockBehaviour.Properties.of(Material.AMETHYST, MaterialColor.DIAMOND).sound(SoundType.AMETHYST).noDrops()
|
new BlockConjured(
|
||||||
|
BlockBehaviour.Properties.of(Material.AMETHYST, MaterialColor.DIAMOND).sound(SoundType.AMETHYST).noDrops()
|
||||||
.instabreak().noOcclusion().isSuffocating(HexBlocks::never).isViewBlocking(HexBlocks::never)));
|
.instabreak().noOcclusion().isSuffocating(HexBlocks::never).isViewBlocking(HexBlocks::never)));
|
||||||
|
public static final RegistryObject<Block> SLATE = registerBlock("slate",
|
||||||
|
new BlockSlate(BlockBehaviour.Properties.of(Material.STONE, MaterialColor.DEEPSLATE)
|
||||||
|
.sound(SoundType.DEEPSLATE_TILES)
|
||||||
|
.strength(2f, 4f)));
|
||||||
|
|
||||||
public static final RegistryObject<BlockEntityType<BlockEntityConjured>> CONJURED_TILE = BLOCK_ENTITIES.register("conjured_tile",
|
public static final RegistryObject<BlockEntityType<BlockEntityConjured>> CONJURED_TILE = BLOCK_ENTITIES.register(
|
||||||
|
"conjured_tile",
|
||||||
() -> BlockEntityType.Builder.of(BlockEntityConjured::new, CONJURED.get()).build(null));
|
() -> BlockEntityType.Builder.of(BlockEntityConjured::new, CONJURED.get()).build(null));
|
||||||
|
public static final RegistryObject<BlockEntityType<BlockEntitySlate>> SLATE_TILE = BLOCK_ENTITIES.register(
|
||||||
|
"slate_tile",
|
||||||
|
() -> BlockEntityType.Builder.of(BlockEntitySlate::new, SLATE.get()).build(null));
|
||||||
|
|
||||||
|
|
||||||
private static RegistryObject<Block> registerBlock(String label, Block block) {
|
private static RegistryObject<Block> registerBlock(String label, Block block) {
|
||||||
ITEMS.register(label, () -> new BlockItem(block, new Item.Properties().tab(TAB)));
|
ITEMS.register(label, () -> new BlockItem(block, new Item.Properties().tab(TAB)));
|
||||||
return BLOCKS.register(label, () -> block);
|
return BLOCKS.register(label, () -> block);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean never(Object ... args) {
|
private static boolean never(Object... args) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue