improved additivity of blocks and added pillar
This commit is contained in:
parent
a430a8e62b
commit
74a290fd16
@ -37,7 +37,7 @@ public class ReFramed implements ModInitializer {
|
|||||||
public static final String MODID = "reframed";
|
public static final String MODID = "reframed";
|
||||||
|
|
||||||
public static final ArrayList<Block> BLOCKS = new ArrayList<>();
|
public static final ArrayList<Block> BLOCKS = new ArrayList<>();
|
||||||
public static Block CUBE, SMALL_CUBE, SMALL_CUBES_STEP, STAIR, HALF_STAIR, STAIRS_CUBE, HALF_STAIRS_SLAB, HALF_STAIRS_STAIR, SLAB, SLABS_CUBE, STEP, STEPS_SLAB, LAYER;
|
public static Block CUBE, SMALL_CUBE, SMALL_CUBES_STEP, STAIR, HALF_STAIR, STAIRS_CUBE, HALF_STAIRS_SLAB, HALF_STAIRS_STAIR, SLAB, SLABS_CUBE, STEP, STEPS_SLAB, LAYER, PILLAR;
|
||||||
|
|
||||||
public static final ArrayList<Item> ITEMS = new ArrayList<>();
|
public static final ArrayList<Item> ITEMS = new ArrayList<>();
|
||||||
public static Item HAMMER, SCREWDRIVER, BLUEPRINT, BLUEPRINT_WRITTEN;
|
public static Item HAMMER, SCREWDRIVER, BLUEPRINT, BLUEPRINT_WRITTEN;
|
||||||
@ -64,6 +64,7 @@ public class ReFramed implements ModInitializer {
|
|||||||
SLABS_CUBE = registerBlock("slabs_cube" , new ReFramedSlabsCubeBlock(cp(Blocks.OAK_SLAB)));
|
SLABS_CUBE = registerBlock("slabs_cube" , new ReFramedSlabsCubeBlock(cp(Blocks.OAK_SLAB)));
|
||||||
STEP = registerBlock("step" , new ReFramedStepBlock(cp(Blocks.OAK_SLAB)));
|
STEP = registerBlock("step" , new ReFramedStepBlock(cp(Blocks.OAK_SLAB)));
|
||||||
STEPS_SLAB = registerBlock("steps_slab" , new ReFramedStepsSlabBlock(cp(Blocks.OAK_SLAB)));
|
STEPS_SLAB = registerBlock("steps_slab" , new ReFramedStepsSlabBlock(cp(Blocks.OAK_SLAB)));
|
||||||
|
PILLAR = registerBlock("pillar" , new ReFramedPillarBlock(cp(Blocks.OAK_FENCE)));
|
||||||
|
|
||||||
HAMMER = registerItem("hammer" , new ReFramedHammerItem(new Item.Settings().maxCount(1)));
|
HAMMER = registerItem("hammer" , new ReFramedHammerItem(new Item.Settings().maxCount(1)));
|
||||||
SCREWDRIVER = registerItem("screwdriver" , new ReFramedScrewdriverItem(new Item.Settings().maxCount(1)));
|
SCREWDRIVER = registerItem("screwdriver" , new ReFramedScrewdriverItem(new Item.Settings().maxCount(1)));
|
||||||
|
@ -7,7 +7,6 @@ import net.minecraft.block.BlockState;
|
|||||||
import net.minecraft.block.ShapeContext;
|
import net.minecraft.block.ShapeContext;
|
||||||
import net.minecraft.block.entity.BlockEntity;
|
import net.minecraft.block.entity.BlockEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.state.property.Property;
|
|
||||||
import net.minecraft.util.ActionResult;
|
import net.minecraft.util.ActionResult;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.hit.BlockHitResult;
|
import net.minecraft.util.hit.BlockHitResult;
|
||||||
@ -50,22 +49,7 @@ public abstract class ReFramedDoubleBlock extends ReFramedBlock {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SafeVarargs
|
public boolean matchesShape(Vec3d hit, BlockPos pos, BlockState state, int i) {
|
||||||
public final <T extends Comparable<T>> boolean matchesAnyOutline(Vec3d hit, BlockPos pos, Property<T> property, T... values) {
|
|
||||||
for (T value : values)
|
|
||||||
if (matchesOutline(hit, pos, property, value)) return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T extends Comparable<T>> boolean matchesOutline(Vec3d hit, BlockPos pos, Property<T> property, T value) {
|
|
||||||
Vec3d rel = BlockHelper.getRelativePos(hit, pos);
|
|
||||||
return BlockHelper.cursorMatchesFace(
|
|
||||||
getOutlineShape(getDefaultState().with(property, value), null, null, null),
|
|
||||||
rel
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T extends Comparable<T>> boolean matchesShape(Vec3d hit, BlockPos pos, BlockState state, int i) {
|
|
||||||
Vec3d rel = BlockHelper.getRelativePos(hit, pos);
|
Vec3d rel = BlockHelper.getRelativePos(hit, pos);
|
||||||
return BlockHelper.cursorMatchesFace(
|
return BlockHelper.cursorMatchesFace(
|
||||||
getShape(state, i),
|
getShape(state, i),
|
||||||
|
@ -34,6 +34,7 @@ import static fr.adrien1106.reframed.util.VoxelHelper.VoxelListBuilder;
|
|||||||
import static fr.adrien1106.reframed.util.blocks.BlockProperties.*;
|
import static fr.adrien1106.reframed.util.blocks.BlockProperties.*;
|
||||||
import static fr.adrien1106.reframed.util.blocks.Corner.*;
|
import static fr.adrien1106.reframed.util.blocks.Corner.*;
|
||||||
import static net.minecraft.data.client.VariantSettings.Rotation.*;
|
import static net.minecraft.data.client.VariantSettings.Rotation.*;
|
||||||
|
import static net.minecraft.state.property.Properties.WATERLOGGED;
|
||||||
|
|
||||||
public class ReFramedHalfStairBlock extends WaterloggableReFramedBlock implements BlockStateProvider {
|
public class ReFramedHalfStairBlock extends WaterloggableReFramedBlock implements BlockStateProvider {
|
||||||
|
|
||||||
@ -63,12 +64,35 @@ public class ReFramedHalfStairBlock extends WaterloggableReFramedBlock implement
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canReplace(BlockState state, ItemPlacementContext context) {
|
public boolean canReplace(BlockState state, ItemPlacementContext context) {
|
||||||
|
Direction dir = state.get(CORNER).getDirection(state.get(CORNER_FACE));
|
||||||
return !(
|
return !(
|
||||||
context.getPlayer().isSneaking()
|
context.getPlayer().isSneaking()
|
||||||
|| !(context.getStack().getItem() instanceof BlockItem block_item)
|
|| !(context.getStack().getItem() instanceof BlockItem block_item)
|
||||||
|| (
|
|| (
|
||||||
block_item.getBlock() != this
|
!(
|
||||||
&& block_item.getBlock() != ReFramed.SMALL_CUBE
|
block_item.getBlock() == this
|
||||||
|
&& ((ReFramedHalfStairsStairBlock) ReFramed.HALF_STAIRS_STAIR)
|
||||||
|
.matchesShape(
|
||||||
|
context.getHitPos(),
|
||||||
|
context.getBlockPos(),
|
||||||
|
ReFramed.HALF_STAIRS_STAIR.getDefaultState()
|
||||||
|
.with(EDGE, state.get(CORNER).getEdge(dir)),
|
||||||
|
dir.getDirection() == Direction.AxisDirection.POSITIVE ? 1 : 2
|
||||||
|
)
|
||||||
|
)
|
||||||
|
&& !(
|
||||||
|
block_item.getBlock() == ReFramed.SMALL_CUBE
|
||||||
|
&& BlockHelper.cursorMatchesFace(
|
||||||
|
ReFramed.SMALL_CUBE.getOutlineShape(
|
||||||
|
ReFramed.SMALL_CUBE.getDefaultState()
|
||||||
|
.with(CORNER, state.get(CORNER).getOpposite(state.get(CORNER_FACE))),
|
||||||
|
context.getWorld(),
|
||||||
|
context.getBlockPos(),
|
||||||
|
ShapeContext.absent()
|
||||||
|
),
|
||||||
|
BlockHelper.getRelativePos(context.getHitPos(), context.getBlockPos())
|
||||||
|
)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -80,12 +104,14 @@ public class ReFramedHalfStairBlock extends WaterloggableReFramedBlock implement
|
|||||||
Corner corner = current_state.get(CORNER).getOpposite(ctx.getSide().getOpposite());
|
Corner corner = current_state.get(CORNER).getOpposite(ctx.getSide().getOpposite());
|
||||||
return ReFramed.HALF_STAIRS_SLAB.getDefaultState()
|
return ReFramed.HALF_STAIRS_SLAB.getDefaultState()
|
||||||
.with(CORNER, corner)
|
.with(CORNER, corner)
|
||||||
.with(CORNER_FACE, corner.getDirectionIndex(ctx.getSide().getOpposite()));
|
.with(CORNER_FACE, corner.getDirectionIndex(ctx.getSide().getOpposite()))
|
||||||
|
.with(WATERLOGGED, current_state.get(WATERLOGGED));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (current_state.isOf(this))
|
if (current_state.isOf(this))
|
||||||
return ReFramed.HALF_STAIRS_STAIR.getDefaultState()
|
return ReFramed.HALF_STAIRS_STAIR.getDefaultState()
|
||||||
.with(EDGE, current_state.get(CORNER).getEdge(current_state.get(CORNER).getDirection(current_state.get(CORNER_FACE))));
|
.with(EDGE, current_state.get(CORNER).getEdge(current_state.get(CORNER).getDirection(current_state.get(CORNER_FACE))))
|
||||||
|
.with(WATERLOGGED, current_state.get(WATERLOGGED));
|
||||||
|
|
||||||
Corner corner = BlockHelper.getPlacementCorner(ctx);
|
Corner corner = BlockHelper.getPlacementCorner(ctx);
|
||||||
return super.getPlacementState(ctx)
|
return super.getPlacementState(ctx)
|
||||||
|
@ -7,6 +7,7 @@ import net.minecraft.block.Block;
|
|||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.ShapeContext;
|
import net.minecraft.block.ShapeContext;
|
||||||
import net.minecraft.data.client.MultipartBlockStateSupplier;
|
import net.minecraft.data.client.MultipartBlockStateSupplier;
|
||||||
|
import net.minecraft.item.BlockItem;
|
||||||
import net.minecraft.item.ItemPlacementContext;
|
import net.minecraft.item.ItemPlacementContext;
|
||||||
import net.minecraft.state.StateManager;
|
import net.minecraft.state.StateManager;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
@ -52,8 +53,12 @@ public class ReFramedLayerBlock extends ReFramedSlabBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canReplace(BlockState state, ItemPlacementContext ctx) {
|
public boolean canReplace(BlockState state, ItemPlacementContext context) {
|
||||||
return !(!state.isOf(this) || ctx.getPlayer().isSneaking() || state.get(LAYERS) == 8);
|
return !(
|
||||||
|
context.getPlayer().isSneaking()
|
||||||
|
|| !(context.getStack().getItem() instanceof BlockItem block_item)
|
||||||
|
|| !(block_item.getBlock() == this && state.get(LAYERS) < 8)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -0,0 +1,102 @@
|
|||||||
|
package fr.adrien1106.reframed.block;
|
||||||
|
|
||||||
|
import fr.adrien1106.reframed.ReFramed;
|
||||||
|
import fr.adrien1106.reframed.generator.BlockStateProvider;
|
||||||
|
import fr.adrien1106.reframed.generator.GBlockstate;
|
||||||
|
import fr.adrien1106.reframed.util.VoxelHelper;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.ShapeContext;
|
||||||
|
import net.minecraft.data.client.BlockStateSupplier;
|
||||||
|
import net.minecraft.data.client.MultipartBlockStateSupplier;
|
||||||
|
import net.minecraft.item.BlockItem;
|
||||||
|
import net.minecraft.item.ItemPlacementContext;
|
||||||
|
import net.minecraft.state.StateManager;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.Direction;
|
||||||
|
import net.minecraft.util.shape.VoxelShape;
|
||||||
|
import net.minecraft.world.BlockView;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static net.minecraft.data.client.VariantSettings.Rotation.*;
|
||||||
|
import static net.minecraft.state.property.Properties.AXIS;
|
||||||
|
|
||||||
|
public class ReFramedPillarBlock extends WaterloggableReFramedBlock implements BlockStateProvider {
|
||||||
|
|
||||||
|
public static final VoxelShape[] PILLAR_VOXELS;
|
||||||
|
|
||||||
|
public ReFramedPillarBlock(Settings settings) {
|
||||||
|
super(settings);
|
||||||
|
setDefaultState(getDefaultState().with(AXIS, Direction.Axis.Y));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getModelCacheKey(BlockState state) {
|
||||||
|
return state.get(AXIS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getModelStateCount() {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
||||||
|
super.appendProperties(builder.add(AXIS));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canReplace(BlockState state, ItemPlacementContext context) {
|
||||||
|
return !(context.getPlayer().isSneaking()
|
||||||
|
|| !(context.getStack().getItem() instanceof BlockItem block_item)
|
||||||
|
|| !(
|
||||||
|
block_item.getBlock() == this
|
||||||
|
&& state.get(AXIS) != context.getSide().getAxis()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @Nullable BlockState getPlacementState(ItemPlacementContext ctx) {
|
||||||
|
// TODO: PILLARS WALL
|
||||||
|
return super.getPlacementState(ctx).with(AXIS, ctx.getSide().getAxis());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
||||||
|
return getPillarShape(state.get(AXIS));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static VoxelShape getPillarShape(Direction.Axis axis) {
|
||||||
|
return PILLAR_VOXELS[axis.ordinal()];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<Integer, Integer> getThemeMap(BlockState state, BlockState new_state) {
|
||||||
|
// if (new_state.getBlock() == ReFramed.PILLARS_WALL) return Map.of(1, 1); // TODO: PILLARS WALL
|
||||||
|
return super.getThemeMap(state, new_state);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockStateSupplier getMultipart() {
|
||||||
|
Identifier model_id = ReFramed.id("pillar_special");
|
||||||
|
return MultipartBlockStateSupplier.create(this)
|
||||||
|
.with(GBlockstate.when(AXIS, Direction.Axis.X),
|
||||||
|
GBlockstate.variant(model_id, true, R90, R90))
|
||||||
|
.with(GBlockstate.when(AXIS, Direction.Axis.Y),
|
||||||
|
GBlockstate.variant(model_id, true, R0, R0))
|
||||||
|
.with(GBlockstate.when(AXIS, Direction.Axis.Z),
|
||||||
|
GBlockstate.variant(model_id, true, R90, R0));
|
||||||
|
}
|
||||||
|
|
||||||
|
static {
|
||||||
|
final VoxelShape PILLAR = createCuboidShape(0, 4, 4, 16, 12, 12);
|
||||||
|
PILLAR_VOXELS = VoxelHelper.VoxelListBuilder.create(PILLAR, 3)
|
||||||
|
.add(VoxelHelper::rotateZ)
|
||||||
|
.add(VoxelHelper::rotateX)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
@ -63,7 +63,16 @@ public class ReFramedSlabBlock extends WaterloggableReFramedBlock implements Blo
|
|||||||
return !(
|
return !(
|
||||||
context.getPlayer().isSneaking()
|
context.getPlayer().isSneaking()
|
||||||
|| !(context.getStack().getItem() instanceof BlockItem block_item)
|
|| !(context.getStack().getItem() instanceof BlockItem block_item)
|
||||||
|| block_item.getBlock() != this
|
|| !(
|
||||||
|
block_item.getBlock() == this
|
||||||
|
&& ((ReFramedSlabsCubeBlock) ReFramed.SLABS_CUBE)
|
||||||
|
.matchesShape(
|
||||||
|
context.getHitPos(),
|
||||||
|
context.getBlockPos(),
|
||||||
|
ReFramed.SLABS_CUBE.getDefaultState().with(AXIS, state.get(FACING).getAxis()),
|
||||||
|
state.get(FACING).getDirection() == Direction.AxisDirection.POSITIVE ? 1 : 2
|
||||||
|
)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ import static fr.adrien1106.reframed.util.VoxelHelper.VoxelListBuilder;
|
|||||||
import static fr.adrien1106.reframed.util.blocks.BlockProperties.*;
|
import static fr.adrien1106.reframed.util.blocks.BlockProperties.*;
|
||||||
import static fr.adrien1106.reframed.util.blocks.Corner.*;
|
import static fr.adrien1106.reframed.util.blocks.Corner.*;
|
||||||
import static net.minecraft.data.client.VariantSettings.Rotation.*;
|
import static net.minecraft.data.client.VariantSettings.Rotation.*;
|
||||||
|
import static net.minecraft.state.property.Properties.WATERLOGGED;
|
||||||
|
|
||||||
public class ReFramedSmallCubeBlock extends WaterloggableReFramedBlock implements BlockStateProvider {
|
public class ReFramedSmallCubeBlock extends WaterloggableReFramedBlock implements BlockStateProvider {
|
||||||
|
|
||||||
@ -79,22 +80,29 @@ public class ReFramedSmallCubeBlock extends WaterloggableReFramedBlock implement
|
|||||||
)
|
)
|
||||||
&& !(
|
&& !(
|
||||||
block_item.getBlock() == this
|
block_item.getBlock() == this
|
||||||
&& !(
|
&& (
|
||||||
corner.hasDirection(context.getSide())
|
((ReFramedSmallCubesStepBlock) ReFramed.SMALL_CUBES_STEP)
|
||||||
&& BlockHelper.cursorMatchesFace(
|
.matchesShape(
|
||||||
getOutlineShape(state, context.getWorld(), context.getBlockPos(), null),
|
context.getHitPos(),
|
||||||
BlockHelper.getRelativePos(context.getHitPos(), context.getBlockPos())
|
context.getBlockPos(),
|
||||||
)
|
ReFramed.SMALL_CUBES_STEP.getDefaultState().with(EDGE, corner.getEdge(corner.getFirstDirection())),
|
||||||
|
corner.getFirstDirection().getDirection() == Direction.AxisDirection.POSITIVE ? 1 : 2
|
||||||
|
)
|
||||||
|
|| ((ReFramedSmallCubesStepBlock) ReFramed.SMALL_CUBES_STEP)
|
||||||
|
.matchesShape(
|
||||||
|
context.getHitPos(),
|
||||||
|
context.getBlockPos(),
|
||||||
|
ReFramed.SMALL_CUBES_STEP.getDefaultState().with(EDGE, corner.getEdge(corner.getSecondDirection())),
|
||||||
|
corner.getSecondDirection().getDirection() == Direction.AxisDirection.POSITIVE ? 1 : 2
|
||||||
|
)
|
||||||
|
|| ((ReFramedSmallCubesStepBlock) ReFramed.SMALL_CUBES_STEP)
|
||||||
|
.matchesShape(
|
||||||
|
context.getHitPos(),
|
||||||
|
context.getBlockPos(),
|
||||||
|
ReFramed.SMALL_CUBES_STEP.getDefaultState().with(EDGE, corner.getEdge(corner.getThirdDirection())),
|
||||||
|
corner.getThirdDirection().getDirection() == Direction.AxisDirection.POSITIVE ? 1 : 2
|
||||||
|
)
|
||||||
)
|
)
|
||||||
&& ((ReFramedSmallCubesStepBlock) ReFramed.SMALL_CUBES_STEP)
|
|
||||||
.matchesAnyOutline(
|
|
||||||
context.getHitPos(),
|
|
||||||
context.getBlockPos(),
|
|
||||||
EDGE,
|
|
||||||
corner.getEdge(corner.getFirstDirection()),
|
|
||||||
corner.getEdge(corner.getSecondDirection()),
|
|
||||||
corner.getEdge(corner.getThirdDirection())
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -107,23 +115,27 @@ public class ReFramedSmallCubeBlock extends WaterloggableReFramedBlock implement
|
|||||||
if (current_state.isOf(ReFramed.HALF_STAIR))
|
if (current_state.isOf(ReFramed.HALF_STAIR))
|
||||||
return ReFramed.HALF_STAIRS_SLAB.getDefaultState()
|
return ReFramed.HALF_STAIRS_SLAB.getDefaultState()
|
||||||
.with(CORNER, current_state.get(CORNER))
|
.with(CORNER, current_state.get(CORNER))
|
||||||
.with(CORNER_FACE, current_state.get(CORNER_FACE));
|
.with(CORNER_FACE, current_state.get(CORNER_FACE))
|
||||||
|
.with(WATERLOGGED, current_state.get(WATERLOGGED));
|
||||||
|
|
||||||
|
|
||||||
if (current_state.isOf(this)) {
|
if (current_state.isOf(this)) {
|
||||||
Vec3d hit = ctx.getHitPos();
|
Vec3d hit = ctx.getHitPos();
|
||||||
Corner corner = current_state.get(CORNER);
|
Corner corner = current_state.get(CORNER);
|
||||||
ReFramedSmallCubesStepBlock block = ((ReFramedSmallCubesStepBlock) ReFramed.SMALL_CUBES_STEP);
|
ReFramedSmallCubesStepBlock block = ((ReFramedSmallCubesStepBlock) ReFramed.SMALL_CUBES_STEP);
|
||||||
BlockState state = block.getDefaultState().with(EDGE, corner.getEdge(corner.getFirstDirection()));
|
BlockState state = block.getDefaultState()
|
||||||
if (!block.matchesShape(
|
.with(EDGE, corner.getEdge(corner.getFirstDirection()))
|
||||||
|
.with(WATERLOGGED, current_state.get(WATERLOGGED));
|
||||||
|
if (block.matchesShape(
|
||||||
hit, pos, state,
|
hit, pos, state,
|
||||||
corner.getFirstDirection().getDirection() == Direction.AxisDirection.POSITIVE ? 1 : 2
|
corner.getFirstDirection().getDirection() == Direction.AxisDirection.POSITIVE ? 1 : 2
|
||||||
)) state = state.with(EDGE, corner.getEdge(corner.getSecondDirection()));
|
)) return state;
|
||||||
if (!block.matchesShape(
|
state = state.with(EDGE, corner.getEdge(corner.getSecondDirection()));
|
||||||
|
if (block.matchesShape(
|
||||||
hit, pos, state,
|
hit, pos, state,
|
||||||
corner.getSecondDirection().getDirection() == Direction.AxisDirection.POSITIVE ? 1 : 2
|
corner.getSecondDirection().getDirection() == Direction.AxisDirection.POSITIVE ? 1 : 2
|
||||||
)) state = state.with(EDGE, corner.getEdge(corner.getThirdDirection()));
|
)) return state;
|
||||||
return state;
|
return state.with(EDGE, corner.getEdge(corner.getThirdDirection()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.getPlacementState(ctx).with(CORNER, BlockHelper.getPlacementCorner(ctx));
|
return super.getPlacementState(ctx).with(CORNER, BlockHelper.getPlacementCorner(ctx));
|
||||||
|
@ -70,7 +70,16 @@ public class ReFramedStairBlock extends WaterloggableReFramedBlock implements Bl
|
|||||||
return !(
|
return !(
|
||||||
context.getPlayer().isSneaking()
|
context.getPlayer().isSneaking()
|
||||||
|| !(context.getStack().getItem() instanceof BlockItem block_item)
|
|| !(context.getStack().getItem() instanceof BlockItem block_item)
|
||||||
|| block_item.getBlock() != ReFramed.STEP
|
|| !(
|
||||||
|
block_item.getBlock() == ReFramed.STEP
|
||||||
|
&& ((ReFramedStairsCubeBlock) ReFramed.STAIRS_CUBE)
|
||||||
|
.matchesShape(
|
||||||
|
context.getHitPos(),
|
||||||
|
context.getBlockPos(),
|
||||||
|
state,
|
||||||
|
2
|
||||||
|
)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,8 +34,8 @@ import static fr.adrien1106.reframed.util.blocks.BlockProperties.EDGE;
|
|||||||
import static fr.adrien1106.reframed.util.blocks.BlockProperties.STAIR_SHAPE;
|
import static fr.adrien1106.reframed.util.blocks.BlockProperties.STAIR_SHAPE;
|
||||||
import static fr.adrien1106.reframed.util.blocks.Edge.*;
|
import static fr.adrien1106.reframed.util.blocks.Edge.*;
|
||||||
import static net.minecraft.data.client.VariantSettings.Rotation.*;
|
import static net.minecraft.data.client.VariantSettings.Rotation.*;
|
||||||
import static net.minecraft.state.property.Properties.AXIS;
|
import static net.minecraft.state.property.Properties.*;
|
||||||
import static net.minecraft.state.property.Properties.FACING;
|
import static net.minecraft.state.property.Properties.WATERLOGGED;
|
||||||
|
|
||||||
public class ReFramedStepBlock extends WaterloggableReFramedBlock implements BlockStateProvider {
|
public class ReFramedStepBlock extends WaterloggableReFramedBlock implements BlockStateProvider {
|
||||||
|
|
||||||
@ -68,24 +68,39 @@ public class ReFramedStepBlock extends WaterloggableReFramedBlock implements Blo
|
|||||||
context.getPlayer().isSneaking()
|
context.getPlayer().isSneaking()
|
||||||
|| !(context.getStack().getItem() instanceof BlockItem block_item)
|
|| !(context.getStack().getItem() instanceof BlockItem block_item)
|
||||||
|| (
|
|| (
|
||||||
block_item.getBlock() != ReFramed.STAIR
|
!(
|
||||||
&& !(
|
block_item.getBlock() == ReFramed.STAIR
|
||||||
block_item.getBlock() == this
|
&& ((ReFramedStairsCubeBlock) ReFramed.STAIRS_CUBE)
|
||||||
&& !(
|
.matchesShape(
|
||||||
(edge.isSide(context.getSide()) || edge.hasDirection(context.getSide()))
|
|
||||||
&& BlockHelper.cursorMatchesFace(
|
|
||||||
getOutlineShape(state, context.getWorld(), context.getBlockPos(), null),
|
|
||||||
BlockHelper.getRelativePos(context.getHitPos(), context.getBlockPos())
|
|
||||||
)
|
|
||||||
)
|
|
||||||
&& ((ReFramedStepsSlabBlock) ReFramed.STEPS_SLAB)
|
|
||||||
.matchesAnyOutline(
|
|
||||||
context.getHitPos(),
|
context.getHitPos(),
|
||||||
context.getBlockPos(),
|
context.getBlockPos(),
|
||||||
FACING,
|
ReFramed.STAIRS_CUBE.getDefaultState().with(EDGE, edge.opposite()),
|
||||||
edge.getFirstDirection(),
|
1
|
||||||
edge.getSecondDirection()
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
)
|
||||||
|
&& !(
|
||||||
|
block_item.getBlock() == this
|
||||||
|
&& (
|
||||||
|
((ReFramedStepsSlabBlock) ReFramed.STEPS_SLAB)
|
||||||
|
.matchesShape(
|
||||||
|
context.getHitPos(),
|
||||||
|
context.getBlockPos(),
|
||||||
|
ReFramed.STEPS_SLAB.getDefaultState()
|
||||||
|
.with(FACING, edge.getFirstDirection())
|
||||||
|
.with(AXIS, edge.getSecondDirection().getAxis()),
|
||||||
|
edge.getSecondDirection().getDirection() == Direction.AxisDirection.POSITIVE ? 1 : 2
|
||||||
|
)
|
||||||
|
|| ((ReFramedStepsSlabBlock) ReFramed.STEPS_SLAB)
|
||||||
|
.matchesShape(
|
||||||
|
context.getHitPos(),
|
||||||
|
context.getBlockPos(),
|
||||||
|
ReFramed.STEPS_SLAB.getDefaultState()
|
||||||
|
.with(FACING, edge.getSecondDirection())
|
||||||
|
.with(AXIS, edge.getFirstDirection().getAxis()),
|
||||||
|
edge.getFirstDirection().getDirection() == Direction.AxisDirection.POSITIVE ? 1 : 2
|
||||||
|
)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -109,7 +124,8 @@ public class ReFramedStepBlock extends WaterloggableReFramedBlock implements Blo
|
|||||||
ReFramedStepsSlabBlock block = ((ReFramedStepsSlabBlock) ReFramed.STEPS_SLAB);
|
ReFramedStepsSlabBlock block = ((ReFramedStepsSlabBlock) ReFramed.STEPS_SLAB);
|
||||||
BlockState state = block.getDefaultState()
|
BlockState state = block.getDefaultState()
|
||||||
.with(FACING, dir)
|
.with(FACING, dir)
|
||||||
.with(AXIS, edge.getOtherDirection(dir).getAxis());
|
.with(AXIS, edge.getOtherDirection(dir).getAxis())
|
||||||
|
.with(WATERLOGGED, current_state.get(WATERLOGGED));
|
||||||
if (!block.matchesShape(
|
if (!block.matchesShape(
|
||||||
hit, pos,
|
hit, pos,
|
||||||
state,
|
state,
|
||||||
|
@ -73,6 +73,8 @@ public class ReFramedClient implements ClientModInitializer {
|
|||||||
HELPER.addReFramedModel("layer_6_special" , HELPER.auto(new Identifier("block/snow_height12")));
|
HELPER.addReFramedModel("layer_6_special" , HELPER.auto(new Identifier("block/snow_height12")));
|
||||||
HELPER.addReFramedModel("layer_7_special" , HELPER.auto(new Identifier("block/snow_height14")));
|
HELPER.addReFramedModel("layer_7_special" , HELPER.auto(new Identifier("block/snow_height14")));
|
||||||
HELPER.addReFramedModel("layer_8_special" , HELPER.auto(new Identifier("block/cube")));
|
HELPER.addReFramedModel("layer_8_special" , HELPER.auto(new Identifier("block/cube")));
|
||||||
|
// PILLAR
|
||||||
|
HELPER.addReFramedModel("pillar_special" , HELPER.auto(ReFramed.id("block/pillar")));
|
||||||
|
|
||||||
//item model assignments (in lieu of models/item/___.json)
|
//item model assignments (in lieu of models/item/___.json)
|
||||||
HELPER.assignItemModel("cube_special" , ReFramed.CUBE);
|
HELPER.assignItemModel("cube_special" , ReFramed.CUBE);
|
||||||
@ -88,6 +90,7 @@ public class ReFramedClient implements ClientModInitializer {
|
|||||||
HELPER.assignItemModel("step_special" , ReFramed.STEP);
|
HELPER.assignItemModel("step_special" , ReFramed.STEP);
|
||||||
HELPER.assignItemModel("steps_slab_special" , ReFramed.STEPS_SLAB);
|
HELPER.assignItemModel("steps_slab_special" , ReFramed.STEPS_SLAB);
|
||||||
HELPER.assignItemModel("layer_1_special" , ReFramed.LAYER);
|
HELPER.assignItemModel("layer_1_special" , ReFramed.LAYER);
|
||||||
|
HELPER.assignItemModel("pillar_special" , ReFramed.PILLAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void privateInit() {
|
private void privateInit() {
|
||||||
|
21
src/main/resources/assets/reframed/models/block/pillar.json
Normal file
21
src/main/resources/assets/reframed/models/block/pillar.json
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"credit": "Made with Blockbench",
|
||||||
|
"parent": "block/block",
|
||||||
|
"textures": {
|
||||||
|
"particle": "#side"
|
||||||
|
},
|
||||||
|
"elements": [
|
||||||
|
{
|
||||||
|
"from": [4, 0, 4],
|
||||||
|
"to": [12, 16, 12],
|
||||||
|
"faces": {
|
||||||
|
"north": {"uv": [4, 0, 12, 16], "texture": "#side"},
|
||||||
|
"east": {"uv": [4, 0, 12, 16], "texture": "#side"},
|
||||||
|
"south": {"uv": [4, 0, 12, 16], "texture": "#side"},
|
||||||
|
"west": {"uv": [4, 0, 12, 16], "texture": "#side"},
|
||||||
|
"up": {"uv": [4, 4, 12, 12], "texture": "#top", "cullface": "up"},
|
||||||
|
"down": {"uv": [4, 4, 12, 12], "texture": "#bottom", "cullface": "down"}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user