Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c80d3c4167 | |||
| fd26f5da4a | |||
| dbcb79f992 | |||
| 8d8a0e3654 | |||
| 5c6fbff52e | |||
| 17f5c378cd | |||
| 2f9cf1e57d | |||
| a470724d81 | |||
| b825959626 | |||
| 083d39562a | |||
| 9e40de85e3 | |||
| e592db1ea2 | |||
| 1fa55064c7 | |||
| e8c06a7fb3 | |||
| d7ae1f646f | |||
| e3dac8a77f | |||
| 5281f84a2a |
@@ -9,7 +9,7 @@ loader_version=0.15.11
|
||||
|
||||
# Mod Properties
|
||||
modrinth_id = jCpoCBpn
|
||||
mod_version = 1.6.5
|
||||
mod_version = 1.6.8
|
||||
maven_group = fr.adrien1106
|
||||
archives_base_name = ReFramed
|
||||
mod_id = reframed
|
||||
|
||||
@@ -41,7 +41,7 @@ public class ReFramed implements ModInitializer {
|
||||
SMALL_CUBE, SMALL_CUBES_STEP,
|
||||
STAIR, STAIRS_CUBE,
|
||||
HALF_STAIR, HALF_STAIRS_SLAB, HALF_STAIRS_STAIR, HALF_STAIRS_CUBE_STAIR, HALF_STAIRS_STEP_STAIR,
|
||||
SLAB, SLABS_CUBE, SLABS_STAIR, SLABS_OUTER_STAIR, SLABS_INNER_STAIR, SLABS_HALF_LAYER,
|
||||
SLAB, SLABS_CUBE, SLABS_STAIR, SLABS_OUTER_STAIR, SLABS_INNER_STAIR, SLABS_HALF_LAYER, SLABS_LAYER,
|
||||
HALF_SLAB, HALF_SLABS_SLAB,
|
||||
STEP, STEPS_SLAB, STEPS_CROSS, STEPS_HALF_LAYER,
|
||||
LAYER, HALF_LAYER,
|
||||
@@ -80,6 +80,7 @@ public class ReFramed implements ModInitializer {
|
||||
SLABS_OUTER_STAIR = registerBlock("slabs_outer_stair" , new ReFramedSlabsOuterStairBlock(cp(Blocks.OAK_STAIRS)));
|
||||
SLABS_INNER_STAIR = registerBlock("slabs_inner_stair" , new ReFramedSlabsInnerStairBlock(cp(Blocks.OAK_STAIRS)));
|
||||
SLABS_HALF_LAYER = registerBlock("slabs_half_layer" , new ReFramedSlabsHalfLayerBlock(cp(Blocks.OAK_SLAB)));
|
||||
SLABS_LAYER = registerBlock("slabs_layer" , new ReFramedSlabsLayerBlock(cp(Blocks.OAK_SLAB)));
|
||||
HALF_SLAB = registerBlock("half_slab" , new ReFramedHalfSlabBlock(cp(Blocks.OAK_SLAB)));
|
||||
HALF_SLABS_SLAB = registerBlock("half_slabs_slab" , new ReFramedHalfSlabsSlabBlock(cp(Blocks.OAK_SLAB)));
|
||||
STEP = registerBlock("step" , new ReFramedStepBlock(cp(Blocks.OAK_SLAB)));
|
||||
@@ -134,11 +135,11 @@ public class ReFramed implements ModInitializer {
|
||||
private static AbstractBlock.Settings cp(Block base) {
|
||||
return AbstractBlock.Settings.copy(base)
|
||||
.luminance(state -> state.contains(LIGHT) && state.get(LIGHT) ? 15 : 0)
|
||||
.nonOpaque()
|
||||
.sounds(BlockSoundGroup.WOOD)
|
||||
.hardness(0.2f)
|
||||
.suffocates((a,b,c) -> false)
|
||||
.blockVision((a,b,c) -> false);
|
||||
.suffocates(Blocks::never)
|
||||
.solidBlock(Blocks::always);
|
||||
// .blockVision(Blocks::always);
|
||||
}
|
||||
|
||||
private static <I extends Item> I registerItem(String path, I item) {
|
||||
|
||||
@@ -48,8 +48,9 @@ public abstract class CornerDoubleReFramedBlock extends WaterloggableReFramedDou
|
||||
public BlockState rotate(BlockState state, BlockRotation rotation) {
|
||||
Corner corner = state.get(CORNER);
|
||||
Direction face = corner.getDirection(state.get(CORNER_FACE));
|
||||
corner = corner.rotate(rotation);
|
||||
return state
|
||||
.with(CORNER, corner.rotate(rotation))
|
||||
.with(CORNER, corner)
|
||||
.with(CORNER_FACE, corner.getDirectionIndex(rotation.rotate(face)));
|
||||
}
|
||||
|
||||
@@ -58,8 +59,9 @@ public abstract class CornerDoubleReFramedBlock extends WaterloggableReFramedDou
|
||||
public BlockState mirror(BlockState state, BlockMirror mirror) {
|
||||
Corner corner = state.get(CORNER);
|
||||
Direction face = corner.getDirection(state.get(CORNER_FACE));
|
||||
corner = corner.mirror(mirror);
|
||||
return state
|
||||
.with(CORNER, corner.mirror(mirror))
|
||||
.with(CORNER, corner)
|
||||
.with(CORNER_FACE, corner.getDirectionIndex(mirror.apply(face)));
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package fr.adrien1106.reframed.block;
|
||||
|
||||
import net.minecraft.block.AbstractBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.ShapeContext;
|
||||
import net.minecraft.item.ItemPlacementContext;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.util.BlockMirror;
|
||||
import net.minecraft.util.BlockRotation;
|
||||
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 static net.minecraft.state.property.Properties.FACING;
|
||||
|
||||
public abstract class FacingDoubleReFramedBlock extends WaterloggableReFramedDoubleBlock {
|
||||
|
||||
public FacingDoubleReFramedBlock(AbstractBlock.Settings settings) {
|
||||
super(settings);
|
||||
setDefaultState(getDefaultState().with(FACING, Direction.DOWN));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendProperties(StateManager.Builder< Block, BlockState > builder) {
|
||||
super.appendProperties(builder.add(FACING));
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable BlockState getPlacementState(ItemPlacementContext ctx) {
|
||||
return super.getPlacementState(ctx)
|
||||
.with(FACING, ctx.getSide().getOpposite());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public abstract VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context);
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public BlockState rotate(BlockState state, BlockRotation rotation) {
|
||||
return state
|
||||
.with(FACING, rotation.rotate(state.get(FACING)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public BlockState mirror(BlockState state, BlockMirror mirror) {
|
||||
return state.with(FACING, mirror.apply(state.get(FACING)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract VoxelShape getShape(BlockState state, int i);
|
||||
|
||||
}
|
||||
@@ -24,7 +24,8 @@ public abstract class HalfLayerDoubleReFramedBlock extends EdgeDoubleReFramedBlo
|
||||
@SuppressWarnings("deprecation")
|
||||
public List<ItemStack> getDroppedStacks(BlockState state, LootContextParameterSet.Builder builder) {
|
||||
List<ItemStack> drops = super.getDroppedStacks(state, builder);
|
||||
drops.add(new ItemStack(ReFramed.HALF_LAYER, state.get(LAYERS)-1));
|
||||
if (state.get(LAYERS) > 1)
|
||||
drops.add(new ItemStack(ReFramed.HALF_LAYER, state.get(LAYERS)-1));
|
||||
return drops;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,9 +2,11 @@ package fr.adrien1106.reframed.block;
|
||||
|
||||
import fr.adrien1106.reframed.ReFramed;
|
||||
import fr.adrien1106.reframed.util.blocks.BlockHelper;
|
||||
import fr.adrien1106.reframed.util.blocks.ThemeableBlockEntity;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.ai.pathing.NavigationType;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemPlacementContext;
|
||||
@@ -17,6 +19,7 @@ import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.ItemScatterer;
|
||||
import net.minecraft.util.collection.DefaultedList;
|
||||
import net.minecraft.util.function.BooleanBiFunction;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
@@ -31,6 +34,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import static fr.adrien1106.reframed.block.ReFramedEntity.BLOCKSTATE_KEY;
|
||||
@@ -39,10 +43,26 @@ import static fr.adrien1106.reframed.util.blocks.BlockProperties.LIGHT;
|
||||
public class ReFramedBlock extends Block implements BlockEntityProvider {
|
||||
|
||||
public ReFramedBlock(Settings settings) {
|
||||
super(settings);
|
||||
super(settings.dynamicBounds());
|
||||
setDefaultState(getDefaultState().with(LIGHT, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public int getOpacity(BlockState state, BlockView world, BlockPos pos) {
|
||||
if (state.get(LIGHT)) return 0;
|
||||
if (!(world.getBlockEntity(pos) instanceof ReFramedEntity frame_entity)
|
||||
|| frame_entity.getTheme(0).isOpaque())
|
||||
return world.getMaxLightLevel();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean canPathfindThrough(BlockState state, BlockView world, BlockPos pos, NavigationType type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
|
||||
return ReFramed.REFRAMED_BLOCK_ENTITY.instantiate(pos, state);
|
||||
@@ -208,4 +228,17 @@ public class ReFramedBlock extends Block implements BlockEntityProvider {
|
||||
public Map<Integer, Integer> getThemeMap(BlockState state, BlockState new_state) {
|
||||
return Map.of();
|
||||
}
|
||||
|
||||
public VoxelShape getShadingShape(BlockState state, BlockView world, BlockPos pos) {
|
||||
if (!(world.getBlockEntity(pos) instanceof ThemeableBlockEntity framed_entity)) return this.getCollisionShape(state, world, pos, ShapeContext.absent());
|
||||
|
||||
AtomicInteger i = new AtomicInteger(1);
|
||||
return framed_entity.getThemes().stream().map((theme) -> {
|
||||
int index = i.getAndIncrement();
|
||||
return theme.isTransparent(world, pos) ? VoxelShapes.empty() : this.getShape(state, index);
|
||||
}).reduce(
|
||||
VoxelShapes.empty(),
|
||||
(prev, current) -> VoxelShapes.combine(prev, current, BooleanBiFunction.OR)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,12 +32,12 @@ public class ReFramedEntity extends BlockEntity implements ThemeableBlockEntity
|
||||
protected BlockState first_state = Blocks.AIR.getDefaultState();
|
||||
protected byte bit_field = SOLIDITY_MASK;
|
||||
|
||||
protected static final byte LIGHT_MASK = 0b001;
|
||||
protected static final byte REDSTONE_MASK = 0b010;
|
||||
protected static final byte SOLIDITY_MASK = 0b100;
|
||||
public static final byte LIGHT_MASK = 0b001;
|
||||
public static final byte REDSTONE_MASK = 0b010;
|
||||
public static final byte SOLIDITY_MASK = 0b100;
|
||||
|
||||
public static final String BLOCKSTATE_KEY = "s";
|
||||
protected static final String BITFIELD_KEY = "b";
|
||||
public static final String BITFIELD_KEY = "b";
|
||||
|
||||
public ReFramedEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
|
||||
super(type, pos, state);
|
||||
@@ -145,7 +145,10 @@ public class ReFramedEntity extends BlockEntity implements ThemeableBlockEntity
|
||||
if (isSolid()) bit_field &= ~SOLIDITY_MASK;
|
||||
else bit_field |= SOLIDITY_MASK;
|
||||
|
||||
if(world != null) world.setBlockState(pos, getCachedState());
|
||||
if(world != null) {
|
||||
world.setBlockState(pos, getCachedState());
|
||||
ReFramed.chunkRerenderProxy.accept(world, pos);
|
||||
}
|
||||
markDirtyAndDispatch();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,62 +1,30 @@
|
||||
package fr.adrien1106.reframed.block;
|
||||
|
||||
import fr.adrien1106.reframed.util.VoxelHelper;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.ShapeContext;
|
||||
import net.minecraft.item.ItemPlacementContext;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.util.BlockMirror;
|
||||
import net.minecraft.util.BlockRotation;
|
||||
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 static fr.adrien1106.reframed.block.ReFramedHalfSlabBlock.getHalfSlabShape;
|
||||
import static fr.adrien1106.reframed.block.ReFramedSlabBlock.getSlabShape;
|
||||
import static net.minecraft.state.property.Properties.FACING;
|
||||
|
||||
public class ReFramedHalfSlabsSlabBlock extends WaterloggableReFramedDoubleBlock {
|
||||
public class ReFramedHalfSlabsSlabBlock extends FacingDoubleReFramedBlock {
|
||||
|
||||
public static VoxelShape[] HALF_SLAB_COMP_SHAPES;
|
||||
|
||||
public ReFramedHalfSlabsSlabBlock(Settings settings) {
|
||||
super(settings);
|
||||
setDefaultState(getDefaultState().with(FACING, Direction.DOWN));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
||||
super.appendProperties(builder.add(FACING));
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable BlockState getPlacementState(ItemPlacementContext ctx) {
|
||||
return super.getPlacementState(ctx)
|
||||
.with(FACING, ctx.getSide().getOpposite());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
||||
return getSlabShape(state.get(FACING));
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public BlockState rotate(BlockState state, BlockRotation rotation) {
|
||||
return state
|
||||
.with(FACING, rotation.rotate(state.get(FACING)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public BlockState mirror(BlockState state, BlockMirror mirror) {
|
||||
return state.with(FACING, mirror.apply(state.get(FACING)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, int i) {
|
||||
Direction face = state.get(FACING);
|
||||
|
||||
@@ -73,6 +73,13 @@ public class ReFramedHalfStairBlock extends WaterloggableReFramedBlock {
|
||||
ReFramed.SMALL_CUBE.getDefaultState().with(CORNER, corner.getOpposite(dir))
|
||||
);
|
||||
|
||||
if (block == ReFramed.SLAB)
|
||||
return ReFramed.SLAB.matchesShape(
|
||||
context.getHitPos(),
|
||||
context.getBlockPos(),
|
||||
ReFramed.SLAB.getDefaultState().with(FACING, dir.getOpposite())
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -135,6 +142,7 @@ public class ReFramedHalfStairBlock extends WaterloggableReFramedBlock {
|
||||
|| new_state.isOf(ReFramed.HALF_STAIRS_CUBE_STAIR)
|
||||
|| new_state.isOf(ReFramed.HALF_STAIRS_STEP_STAIR)
|
||||
) return Map.of(1, 1);
|
||||
if (new_state.isOf(ReFramed.SLABS_INNER_STAIR)) return Map.of(1, 2);
|
||||
if (new_state.isOf(ReFramed.HALF_STAIRS_STAIR))
|
||||
return Map.of(
|
||||
1,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package fr.adrien1106.reframed.block;
|
||||
|
||||
import fr.adrien1106.reframed.ReFramed;
|
||||
import fr.adrien1106.reframed.util.VoxelHelper;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
@@ -15,8 +16,8 @@ import net.minecraft.world.BlockView;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import static fr.adrien1106.reframed.util.VoxelHelper.VoxelListBuilder;
|
||||
import static net.minecraft.state.property.Properties.FACING;
|
||||
import static net.minecraft.state.property.Properties.LAYERS;
|
||||
import static fr.adrien1106.reframed.util.blocks.BlockProperties.HALF_LAYERS;
|
||||
import static net.minecraft.state.property.Properties.*;
|
||||
|
||||
public class ReFramedLayerBlock extends LayeredReFramedBlock {
|
||||
|
||||
@@ -34,7 +35,11 @@ public class ReFramedLayerBlock extends LayeredReFramedBlock {
|
||||
|
||||
@Override
|
||||
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
||||
return LAYER_VOXELS[state.get(FACING).getId() * 8 + state.get(LAYERS) - 1];
|
||||
return getLayerShape(state.get(FACING), state.get(LAYERS));
|
||||
}
|
||||
|
||||
public static VoxelShape getLayerShape(Direction facing, int layers) {
|
||||
return LAYER_VOXELS[facing.getId() * 8 + layers - 1];
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -42,6 +47,15 @@ public class ReFramedLayerBlock extends LayeredReFramedBlock {
|
||||
BlockState previous = ctx.getWorld().getBlockState(ctx.getBlockPos());
|
||||
BlockState state = super.getPlacementState(ctx);
|
||||
if (previous.isOf(this)) return state;
|
||||
|
||||
if (previous.isOf(ReFramed.SLAB))
|
||||
return ReFramed.SLABS_LAYER.getDefaultState()
|
||||
.with(FACING, previous.get(FACING))
|
||||
.with(WATERLOGGED, previous.get(WATERLOGGED));
|
||||
|
||||
if (previous.isOf(ReFramed.SLABS_LAYER))
|
||||
return previous.with(HALF_LAYERS, previous.get(HALF_LAYERS) + 1);
|
||||
|
||||
return state.with(FACING, ctx.getSide().getOpposite());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package fr.adrien1106.reframed.block;
|
||||
|
||||
import fr.adrien1106.reframed.ReFramed;
|
||||
import fr.adrien1106.reframed.util.blocks.BlockHelper;
|
||||
import fr.adrien1106.reframed.util.blocks.Corner;
|
||||
import fr.adrien1106.reframed.util.blocks.Edge;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
@@ -19,8 +21,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static fr.adrien1106.reframed.util.blocks.BlockProperties.EDGE;
|
||||
import static fr.adrien1106.reframed.util.blocks.BlockProperties.EDGE_FACE;
|
||||
import static fr.adrien1106.reframed.util.blocks.BlockProperties.*;
|
||||
import static net.minecraft.state.property.Properties.*;
|
||||
|
||||
public class ReFramedSlabBlock extends WaterloggableReFramedBlock {
|
||||
@@ -57,16 +58,15 @@ public class ReFramedSlabBlock extends WaterloggableReFramedBlock {
|
||||
&& block != ReFramed.SMALL_CUBE
|
||||
&& block != ReFramed.HALF_STAIR
|
||||
&& block != ReFramed.HALF_LAYER
|
||||
&& block != ReFramed.LAYER
|
||||
) return false;
|
||||
|
||||
// check if the player is clicking on the inner part of the block
|
||||
return 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
|
||||
);
|
||||
return matchesShape(
|
||||
context.getHitPos(),
|
||||
context.getBlockPos(),
|
||||
state.with(FACING, state.get(FACING).getOpposite())
|
||||
);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -89,6 +89,72 @@ public class ReFramedSlabBlock extends WaterloggableReFramedBlock {
|
||||
.with(WATERLOGGED, current_state.get(WATERLOGGED));
|
||||
}
|
||||
|
||||
if (current_state.isOf(ReFramed.HALF_STAIR)) {
|
||||
Corner corner = current_state.get(CORNER);
|
||||
Direction face = corner.getDirection(current_state.get(CORNER_FACE));
|
||||
corner = corner.change(face);
|
||||
return ReFramed.SLABS_INNER_STAIR.getDefaultState()
|
||||
.with(CORNER, corner)
|
||||
.with(CORNER_FACE, corner.getDirectionIndex(face.getOpposite()))
|
||||
.with(WATERLOGGED, current_state.get(WATERLOGGED));
|
||||
}
|
||||
|
||||
if (current_state.isOf(ReFramed.STEP)) {
|
||||
Edge edge = current_state.get(EDGE),
|
||||
placed = BlockHelper.getPlacementEdge(ctx),
|
||||
new_edge;
|
||||
Direction face = edge.getFirstDirection(),
|
||||
other = edge.getSecondDirection().getOpposite();
|
||||
|
||||
if (!ReFramed.STEP.matchesShape(
|
||||
ctx.getHitPos(),
|
||||
ctx.getBlockPos(),
|
||||
current_state.with(EDGE, new_edge = edge.getOpposite(face))
|
||||
)
|
||||
&& ctx.getSide() != other.getOpposite()
|
||||
&& (placed.getAxis() == edge.getAxis()
|
||||
|| ctx.getSide() == other
|
||||
|| !placed.hasDirection(other))
|
||||
) {
|
||||
new_edge = edge.getOpposite(edge.getSecondDirection());
|
||||
other = edge.getFirstDirection().getOpposite();
|
||||
}
|
||||
|
||||
return ReFramed.SLABS_STAIR.getDefaultState()
|
||||
.with(EDGE, new_edge)
|
||||
.with(EDGE_FACE, new_edge.getDirectionIndex(other))
|
||||
.with(WATERLOGGED, current_state.get(WATERLOGGED));
|
||||
}
|
||||
|
||||
if (current_state.isOf(ReFramed.SMALL_CUBE)) {
|
||||
Corner corner = current_state.get(CORNER);
|
||||
Edge placed = BlockHelper.getPlacementEdge(ctx);
|
||||
Direction face;
|
||||
Corner new_corner;
|
||||
|
||||
if (!corner.hasDirection(face = ctx.getSide())) {
|
||||
int i = 0;
|
||||
do {
|
||||
face = corner.getDirection(i);
|
||||
new_corner = corner.change(face);
|
||||
} while (!ReFramed.SMALL_CUBE.matchesShape(
|
||||
ctx.getHitPos(),
|
||||
ctx.getBlockPos(),
|
||||
current_state.with(CORNER, new_corner)
|
||||
) && ++i < 3);
|
||||
|
||||
if (i == 3) {
|
||||
face = placed.getOtherDirection(corner.getMatchingDirection(placed)).getOpposite();
|
||||
new_corner = corner.change(face);
|
||||
}
|
||||
} else new_corner = corner.change(face);
|
||||
|
||||
return ReFramed.SLABS_OUTER_STAIR.getDefaultState()
|
||||
.with(CORNER, new_corner)
|
||||
.with(CORNER_FACE, new_corner.getDirectionIndex(face.getOpposite()))
|
||||
.with(WATERLOGGED, current_state.get(WATERLOGGED));
|
||||
}
|
||||
|
||||
return super.getPlacementState(ctx).with(FACING, ctx.getSide().getOpposite());
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
package fr.adrien1106.reframed.block;
|
||||
|
||||
import fr.adrien1106.reframed.ReFramed;
|
||||
import fr.adrien1106.reframed.util.VoxelHelper;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.ShapeContext;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemPlacementContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootContextParameterSet;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.world.BlockView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static fr.adrien1106.reframed.block.ReFramedLayerBlock.getLayerShape;
|
||||
import static fr.adrien1106.reframed.block.ReFramedSlabBlock.getSlabShape;
|
||||
import static fr.adrien1106.reframed.util.blocks.BlockProperties.HALF_LAYERS;
|
||||
import static net.minecraft.state.property.Properties.FACING;
|
||||
|
||||
public class ReFramedSlabsLayerBlock extends FacingDoubleReFramedBlock {
|
||||
|
||||
public static VoxelShape[] HALF_LAYER_SHAPES;
|
||||
|
||||
public ReFramedSlabsLayerBlock(Settings settings) {
|
||||
super(settings);
|
||||
setDefaultState(getDefaultState().with(HALF_LAYERS, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public List<ItemStack> getDroppedStacks(BlockState state, LootContextParameterSet.Builder builder) {
|
||||
List<ItemStack> drops = super.getDroppedStacks(state, builder);
|
||||
if (state.get(HALF_LAYERS) > 1)
|
||||
drops.add(new ItemStack(ReFramed.LAYER, state.get(HALF_LAYERS)-1));
|
||||
return drops;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean canReplace(BlockState state, ItemPlacementContext context) {
|
||||
if (context.getPlayer() == null
|
||||
|| context.getPlayer().isSneaking()
|
||||
|| !(context.getStack().getItem() instanceof BlockItem block_item)
|
||||
) return false;
|
||||
|
||||
return block_item.getBlock() == ReFramed.LAYER && state.get(HALF_LAYERS) < 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
||||
super.appendProperties(builder.add(HALF_LAYERS));
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
||||
return getLayerShape(state.get(FACING), state.get(HALF_LAYERS) + 4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, int i) {
|
||||
Direction face = state.get(FACING);
|
||||
return i == 2
|
||||
? HALF_LAYER_SHAPES[face.getId() * 4 + state.get(HALF_LAYERS)-1]
|
||||
: getSlabShape(face);
|
||||
}
|
||||
|
||||
static {
|
||||
VoxelHelper.VoxelListBuilder builder = VoxelHelper.VoxelListBuilder.create(createCuboidShape(0, 8, 0, 16, 10, 16), 24)
|
||||
.add(createCuboidShape(0, 8, 0, 16, 12, 16))
|
||||
.add(createCuboidShape(0, 8, 0, 16, 14, 16))
|
||||
.add(createCuboidShape(0, 8, 0, 16, 16, 16));
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
builder.add(i, VoxelHelper::mirrorY);
|
||||
}
|
||||
for (int i = 0; i < 4; i++) {
|
||||
builder.add(i, VoxelHelper::rotateX);
|
||||
}
|
||||
for (int i = 0; i < 4; i++) {
|
||||
builder.add(i, VoxelHelper::rotateCX);
|
||||
}
|
||||
for (int i = 0; i < 4; i++) {
|
||||
builder.add(i, VoxelHelper::rotateCZ);
|
||||
}
|
||||
for (int i = 0; i < 4; i++) {
|
||||
builder.add(i, VoxelHelper::rotateZ);
|
||||
}
|
||||
|
||||
HALF_LAYER_SHAPES = builder.build();
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,8 @@ import fr.adrien1106.reframed.ReFramed;
|
||||
import fr.adrien1106.reframed.util.VoxelHelper;
|
||||
import fr.adrien1106.reframed.util.blocks.BlockHelper;
|
||||
import fr.adrien1106.reframed.util.blocks.Corner;
|
||||
import fr.adrien1106.reframed.util.blocks.Edge;
|
||||
import fr.adrien1106.reframed.util.blocks.StairShape;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.ShapeContext;
|
||||
@@ -45,51 +47,51 @@ public class ReFramedSmallCubeBlock extends WaterloggableReFramedBlock {
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean canReplace(BlockState state, ItemPlacementContext context) {
|
||||
if (context.getPlayer() == null) return false;
|
||||
if (context.getPlayer() == null
|
||||
|| context.getPlayer().isSneaking()
|
||||
|| !(context.getStack().getItem() instanceof BlockItem block_item)
|
||||
) return false;
|
||||
|
||||
Block block = block_item.getBlock();
|
||||
Corner corner = state.get(CORNER);
|
||||
return !(
|
||||
context.getPlayer().isSneaking()
|
||||
|| !(context.getStack().getItem() instanceof BlockItem block_item)
|
||||
|| (
|
||||
!(
|
||||
block_item.getBlock() == ReFramed.HALF_STAIR
|
||||
&& !(corner.hasDirection(context.getSide())
|
||||
|| (corner.hasDirection(context.getSide().getOpposite())
|
||||
&& BlockHelper.cursorMatchesFace(
|
||||
getOutlineShape(state, context.getWorld(), context.getBlockPos(), null),
|
||||
BlockHelper.getRelativePos(context.getHitPos(), context.getBlockPos())
|
||||
)
|
||||
)
|
||||
)
|
||||
if (block == this)
|
||||
return matchesShape(
|
||||
context.getHitPos(),
|
||||
context.getBlockPos(),
|
||||
getDefaultState().with(CORNER, corner.change(corner.getFirstDirection()))
|
||||
) || matchesShape(
|
||||
context.getHitPos(),
|
||||
context.getBlockPos(),
|
||||
getDefaultState().with(CORNER, corner.change(corner.getSecondDirection()))
|
||||
) || matchesShape(
|
||||
context.getHitPos(),
|
||||
context.getBlockPos(),
|
||||
getDefaultState().with(CORNER, corner.change(corner.getThirdDirection()))
|
||||
);
|
||||
|
||||
if (block == ReFramed.HALF_STAIR || block == ReFramed.SLAB) {
|
||||
corner = corner.getOpposite();
|
||||
Direction face = corner.getFirstDirection();
|
||||
Edge edge = corner.getEdge(face);
|
||||
if (ReFramed.STAIR.matchesShape(
|
||||
context.getHitPos(),
|
||||
context.getBlockPos(),
|
||||
ReFramed.STAIR.getDefaultState()
|
||||
.with(EDGE, edge)
|
||||
.with(
|
||||
STAIR_SHAPE,
|
||||
face.getDirection() == Direction.AxisDirection.POSITIVE
|
||||
? StairShape.INNER_LEFT
|
||||
: StairShape.INNER_RIGHT
|
||||
)
|
||||
&& !(
|
||||
block_item.getBlock() == this
|
||||
&& (
|
||||
ReFramed.SMALL_CUBES_STEP
|
||||
.matchesShape(
|
||||
context.getHitPos(),
|
||||
context.getBlockPos(),
|
||||
ReFramed.SMALL_CUBES_STEP.getDefaultState().with(EDGE, corner.getEdge(corner.getFirstDirection())),
|
||||
corner.getFirstDirection().getDirection() == Direction.AxisDirection.POSITIVE ? 1 : 2
|
||||
)
|
||||
|| 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
|
||||
)
|
||||
|| 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
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
)) return block == ReFramed.SLAB || !matchesShape(
|
||||
context.getHitPos(),
|
||||
context.getBlockPos(),
|
||||
getDefaultState().with(CORNER, corner)
|
||||
);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -163,7 +165,9 @@ public class ReFramedSmallCubeBlock extends WaterloggableReFramedBlock {
|
||||
|
||||
@Override
|
||||
public Map<Integer, Integer> getThemeMap(BlockState state, BlockState new_state) {
|
||||
if (new_state.isOf(ReFramed.HALF_STAIRS_SLAB)) return Map.of(1, 2);
|
||||
if (new_state.isOf(ReFramed.HALF_STAIRS_SLAB)
|
||||
|| new_state.isOf(ReFramed.SLABS_OUTER_STAIR)
|
||||
) return Map.of(1, 2);
|
||||
if (new_state.isOf(ReFramed.SMALL_CUBES_STEP))
|
||||
return Map.of(
|
||||
1,
|
||||
|
||||
@@ -63,7 +63,10 @@ public class ReFramedStepBlock extends WaterloggableReFramedBlock {
|
||||
);
|
||||
|
||||
// allow replacing with stair
|
||||
if (block != this && block != ReFramed.STAIR) return false;
|
||||
if (block != this
|
||||
&& block != ReFramed.STAIR
|
||||
&& block != ReFramed.SLAB
|
||||
) return false;
|
||||
|
||||
return ReFramed.STAIR
|
||||
.matchesShape(
|
||||
@@ -186,7 +189,8 @@ public class ReFramedStepBlock extends WaterloggableReFramedBlock {
|
||||
if (new_state.isOf(ReFramed.STEPS_CROSS)
|
||||
|| new_state.isOf(ReFramed.STEPS_HALF_LAYER)
|
||||
) return Map.of(1, 1);
|
||||
if (new_state.isOf(ReFramed.STAIRS_CUBE)) return Map.of(1, 2);
|
||||
if (new_state.isOf(ReFramed.STAIRS_CUBE)
|
||||
|| new_state.isOf(ReFramed.SLABS_STAIR)) return Map.of(1, 2);
|
||||
if (new_state.isOf(ReFramed.STEPS_SLAB))
|
||||
return Map.of(
|
||||
1,
|
||||
|
||||
@@ -60,8 +60,7 @@ public class ReFramedStepsCrossBlock extends WaterloggableReFramedDoubleBlock {
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, int i) {
|
||||
// return getStepShape(i == 1 ? state.get(EDGE): state.get(EDGE).opposite());
|
||||
return getOutlineShape(state, null, null, null);
|
||||
return getStepShape(i == 1 ? state.get(EDGE): state.get(EDGE).opposite());
|
||||
}
|
||||
|
||||
static {
|
||||
|
||||
@@ -23,7 +23,13 @@ public class WaterloggableReFramedBlock extends ReFramedBlock implements Waterlo
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
||||
super.appendProperties(builder.add(Properties.WATERLOGGED));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean hasSidedTransparency(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BlockState getPlacementState(ItemPlacementContext ctx) {
|
||||
|
||||
@@ -208,6 +208,12 @@ public class ReFramedClient implements ClientModInitializer {
|
||||
HELPER.addReFramedModel("half_slab" , HELPER.auto(ReFramed.id("block/half_slab/default")));
|
||||
// HALF SLABS SLAB
|
||||
HELPER.addReFramedModel("half_slabs_slab" , HELPER.autoDouble(ReFramed.id("block/half_slab/default"), ReFramed.id("block/half_slab/complement")));
|
||||
// SLABS LAYER
|
||||
HELPER.addReFramedModel("slabs_layer_2" , HELPER.autoDouble(new Identifier("block/slab"), ReFramed.id("block/layer_top/layer_2")));
|
||||
HELPER.addReFramedModel("slabs_layer_4" , HELPER.autoDouble(new Identifier("block/slab"), ReFramed.id("block/layer_top/layer_4")));
|
||||
HELPER.addReFramedModel("slabs_layer_6" , HELPER.autoDouble(new Identifier("block/slab"), ReFramed.id("block/layer_top/layer_6")));
|
||||
HELPER.addReFramedModel("slabs_layer_8" , HELPER.autoDouble(new Identifier("block/slab"), ReFramed.id("block/layer_top/layer_8")));
|
||||
|
||||
|
||||
|
||||
// item model assignments (in lieu of models/item/___.json)
|
||||
@@ -245,6 +251,7 @@ public class ReFramedClient implements ClientModInitializer {
|
||||
HELPER.assignItemModel("steps_half_inventory" , ReFramed.STEPS_HALF_LAYER);
|
||||
HELPER.assignItemModel("half_slab" , ReFramed.HALF_SLAB);
|
||||
HELPER.assignItemModel("half_slabs_slab" , ReFramed.HALF_SLABS_SLAB);
|
||||
HELPER.assignItemModel("slabs_layer_2" , ReFramed.SLABS_LAYER);
|
||||
}
|
||||
|
||||
private void privateInit() {
|
||||
|
||||
@@ -190,9 +190,14 @@ public abstract class RetexturingBakedModel extends ForwardingBakedModel {
|
||||
|
||||
public boolean useAmbientOcclusion(BlockRenderView view, BlockPos pos) {
|
||||
if (!(view.getBlockEntity(pos) instanceof ThemeableBlockEntity frame_entity)) return false;
|
||||
BlockState theme = frame_entity.getTheme(theme_index);
|
||||
CamoAppearance appearance = appearance_manager
|
||||
.getCamoAppearance(view, frame_entity.getTheme(theme_index), pos, theme_index, false);
|
||||
return appearance.getAO(theme_index);
|
||||
.getCamoAppearance(view, theme, pos, theme_index, false);
|
||||
|
||||
long seed = theme.getRenderingSeed(pos);
|
||||
int model_id = 0;
|
||||
if (appearance instanceof WeightedComputedAppearance wca) model_id = wca.getAppearanceIndex(seed);
|
||||
return appearance.getAO(model_id);
|
||||
}
|
||||
|
||||
protected Mesh getRetexturedMesh(MeshCacheKey key, BlockState state) {
|
||||
|
||||
@@ -51,7 +51,7 @@ public class CamoAppearanceManager {
|
||||
for(BlendMode blend : BlendMode.values()) {
|
||||
finder.clear().disableDiffuse(false).blendMode(blend);
|
||||
|
||||
materials.put(blend, finder.ambientOcclusion(TriState.FALSE).find());
|
||||
materials.put(blend, finder.ambientOcclusion(TriState.TRUE).find());
|
||||
ao_materials.put(blend, finder.ambientOcclusion(TriState.DEFAULT).find()); //not "true" since that *forces* AO, i just want to *allow* AO
|
||||
}
|
||||
|
||||
|
||||
@@ -89,8 +89,12 @@ public class RenderHelper {
|
||||
BlockState self_theme = frame_entity.getTheme(theme_index);
|
||||
BlockState other_theme = frame_entity.getTheme(cull_theme);
|
||||
|
||||
if (self_theme.isSideInvisible(other_theme, null)) return false;
|
||||
return !self_theme.isOpaque() || !other_theme.isOpaque();
|
||||
try {
|
||||
if (self_theme.isSideInvisible(other_theme, null)) return false;
|
||||
} catch (NullPointerException e) { // this can happen if mod haven't thought about inner faces
|
||||
return true;
|
||||
}
|
||||
return self_theme.isOpaque() != other_theme.isOpaque() && self_theme.isOpaque();
|
||||
}
|
||||
|
||||
// Doing this method from scratch as it is simpler to do than injecting everywhere
|
||||
@@ -104,7 +108,7 @@ public class RenderHelper {
|
||||
? e : null;
|
||||
|
||||
// normal behaviour
|
||||
if (theme_index == 0 || (self == null && other == null))
|
||||
if ((theme_index == 0 && self != null) || (self == null && other == null))
|
||||
return Block.shouldDrawSide(self_state, world, pos, side, other_pos);
|
||||
|
||||
// self is a normal Block
|
||||
@@ -116,7 +120,7 @@ public class RenderHelper {
|
||||
VoxelShape other_shape = VoxelShapes.empty();
|
||||
for (BlockState s: other.getThemes()) {
|
||||
i++;
|
||||
if (self_state.isSideInvisible(s, side) || s.isOpaque())
|
||||
if (self_state.isSideInvisible(s, side) || (s.isOpaque() && (other.isSolid() || self_state.isTransparent(world ,pos))))
|
||||
other_shape = combine(
|
||||
other_shape,
|
||||
other_block
|
||||
@@ -160,7 +164,7 @@ public class RenderHelper {
|
||||
VoxelShape other_shape = VoxelShapes.empty();
|
||||
for (BlockState s: other.getThemes()) {
|
||||
i++;
|
||||
if (self_theme.isSideInvisible(s, side) || s.isOpaque())
|
||||
if (self_theme.isSideInvisible(s, side) || (s.isOpaque() && (!self.isSolid() || (other.isSolid() == self.isSolid()))))
|
||||
other_shape = combine(
|
||||
other_shape,
|
||||
other_block
|
||||
|
||||
@@ -33,6 +33,7 @@ public class GBlockstate extends FabricModelProvider {
|
||||
providers.put(ReFramedSlabsOuterStairBlock.class, new SlabsOuterStair());
|
||||
providers.put(ReFramedSlabsInnerStairBlock.class, new SlabsInnerStair());
|
||||
providers.put(ReFramedSlabsHalfLayerBlock.class, new SlabsHalfLayer());
|
||||
providers.put(ReFramedSlabsLayerBlock.class, new SlabsLayer());
|
||||
providers.put(ReFramedHalfSlabBlock.class, new HalfSlab());
|
||||
providers.put(ReFramedHalfSlabsSlabBlock.class, new HalfSlabsSlab());
|
||||
providers.put(ReFramedSmallCubeBlock.class, new SmallCube());
|
||||
|
||||
@@ -35,6 +35,7 @@ public class GRecipe extends FabricRecipeProvider {
|
||||
providers.put(ReFramedSlabsOuterStairBlock.class, new SlabsOuterStair());
|
||||
providers.put(ReFramedSlabsInnerStairBlock.class, new SlabsInnerStair());
|
||||
providers.put(ReFramedSlabsHalfLayerBlock.class, new SlabsHalfLayer());
|
||||
providers.put(ReFramedSlabsLayerBlock.class, new SlabsLayer());
|
||||
providers.put(ReFramedHalfSlabBlock.class, new HalfSlab());
|
||||
providers.put(ReFramedHalfSlabsSlabBlock.class, new HalfSlabsSlab());
|
||||
providers.put(ReFramedSmallCubeBlock.class, new SmallCube());
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package fr.adrien1106.reframed.generator.block;
|
||||
|
||||
import fr.adrien1106.reframed.ReFramed;
|
||||
import fr.adrien1106.reframed.generator.BlockStateProvider;
|
||||
import fr.adrien1106.reframed.generator.GBlockstate;
|
||||
import fr.adrien1106.reframed.generator.RecipeSetter;
|
||||
import net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipeProvider;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.data.client.MultipartBlockStateSupplier;
|
||||
import net.minecraft.data.server.recipe.RecipeExporter;
|
||||
import net.minecraft.data.server.recipe.RecipeProvider;
|
||||
import net.minecraft.data.server.recipe.ShapelessRecipeJsonBuilder;
|
||||
import net.minecraft.item.ItemConvertible;
|
||||
import net.minecraft.recipe.book.RecipeCategory;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.Direction;
|
||||
|
||||
import static fr.adrien1106.reframed.util.blocks.BlockProperties.HALF_LAYERS;
|
||||
import static net.minecraft.data.client.VariantSettings.Rotation.*;
|
||||
import static net.minecraft.state.property.Properties.FACING;
|
||||
|
||||
public class SlabsLayer implements RecipeSetter, BlockStateProvider {
|
||||
|
||||
@Override
|
||||
public void setRecipe(RecipeExporter exporter, ItemConvertible convertible) {
|
||||
RecipeProvider.offerStonecuttingRecipe(exporter, RecipeCategory.BUILDING_BLOCKS, convertible, ReFramed.CUBE, 2);
|
||||
ShapelessRecipeJsonBuilder
|
||||
.create(RecipeCategory.BUILDING_BLOCKS, convertible, 1)
|
||||
.input(ReFramed.SLAB)
|
||||
.input(ReFramed.LAYER)
|
||||
.criterion(FabricRecipeProvider.hasItem(ReFramed.CUBE), FabricRecipeProvider.conditionsFromItem(ReFramed.CUBE))
|
||||
.criterion(FabricRecipeProvider.hasItem(convertible), FabricRecipeProvider.conditionsFromItem(convertible))
|
||||
.offerTo(exporter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MultipartBlockStateSupplier getMultipart(Block block) {
|
||||
String model_pattern = "slabs_layer_x_special";
|
||||
MultipartBlockStateSupplier supplier = MultipartBlockStateSupplier.create(block);
|
||||
for (int i = 1; i <= 4; i++) {
|
||||
Identifier model = ReFramed.id(model_pattern.replace("x", i * 2 + ""));
|
||||
supplier
|
||||
.with(GBlockstate.when(FACING, Direction.DOWN, HALF_LAYERS, i),
|
||||
GBlockstate.variant(model, true, R0, R0))
|
||||
.with(GBlockstate.when(FACING, Direction.SOUTH, HALF_LAYERS, i),
|
||||
GBlockstate.variant(model, true, R90, R0))
|
||||
.with(GBlockstate.when(FACING, Direction.UP, HALF_LAYERS, i),
|
||||
GBlockstate.variant(model, true, R180, R0))
|
||||
.with(GBlockstate.when(FACING, Direction.NORTH, HALF_LAYERS, i),
|
||||
GBlockstate.variant(model, true, R270, R0))
|
||||
.with(GBlockstate.when(FACING, Direction.WEST, HALF_LAYERS, i),
|
||||
GBlockstate.variant(model, true, R90, R90))
|
||||
.with(GBlockstate.when(FACING, Direction.EAST, HALF_LAYERS, i),
|
||||
GBlockstate.variant(model, true, R90, R270));
|
||||
}
|
||||
return supplier;
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,8 @@ public class BlockItemMixin {
|
||||
)
|
||||
)
|
||||
private static void placeBlockWithOffHandCamo(World world, PlayerEntity player, BlockPos pos, ItemStack stack, CallbackInfoReturnable<Boolean> cir, @Local LocalRef<NbtCompound> compound) {
|
||||
if (compound.get() != null
|
||||
if (player == null
|
||||
|| compound.get() != null
|
||||
|| player.getOffHandStack().isEmpty()
|
||||
|| player.getMainHandStack().isEmpty()
|
||||
|| !(player.getMainHandStack().getItem() instanceof BlockItem frame)
|
||||
|
||||
@@ -31,6 +31,8 @@ public class CompatMixinPlugin implements IMixinConfigPlugin {
|
||||
CONDITIONS.put("fr.adrien1106.reframed.mixin.compat.IndiumNonTerrainBlockRenderContextMixin", () -> LOADER.isModLoaded(COMPAT_MOD.get(1)));
|
||||
CONDITIONS.put("fr.adrien1106.reframed.mixin.render.BlockRenderContextMixin", () -> !LOADER.isModLoaded(COMPAT_MOD.get(1)));
|
||||
CONDITIONS.put("fr.adrien1106.reframed.mixin.compat.SodiumBlockOcclusionCacheMixin", () -> LOADER.isModLoaded(COMPAT_MOD.get(2)));
|
||||
CONDITIONS.put("fr.adrien1106.reframed.mixin.render.FluidRendererMixin", () -> !LOADER.isModLoaded(COMPAT_MOD.get(2)));
|
||||
CONDITIONS.put("fr.adrien1106.reframed.mixin.compat.SodiumFluidRendererMixin", () -> LOADER.isModLoaded(COMPAT_MOD.get(2)));
|
||||
CONDITIONS.put("fr.adrien1106.reframed.mixin.compat.ContinuityConnectionPredicateMixin", () -> LOADER.isModLoaded(COMPAT_MOD.get(4)));
|
||||
CONDITIONS.put("fr.adrien1106.reframed.mixin.compat.ContinuityCTMBakedModelMixin", () -> LOADER.isModLoaded(COMPAT_MOD.get(4)));
|
||||
CONDITIONS.put("fr.adrien1106.reframed.mixin.compat.ContinuityCTMQuadTransformMixin", () -> LOADER.isModLoaded(COMPAT_MOD.get(4)));
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
package fr.adrien1106.reframed.mixin.compat;
|
||||
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import fr.adrien1106.reframed.block.ReFramedBlock;
|
||||
import fr.adrien1106.reframed.util.blocks.ThemeableBlockEntity;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.compile.pipeline.FluidRenderer;
|
||||
import me.jellysquid.mods.sodium.client.world.WorldSlice;
|
||||
import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandlerRegistry;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(FluidRenderer.class)
|
||||
public abstract class SodiumFluidRendererMixin {
|
||||
|
||||
@Redirect(
|
||||
method = "isSideExposed",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/block/BlockState;isOpaque()Z"
|
||||
)
|
||||
)
|
||||
private boolean isSideOpaqueExposed(BlockState state) {
|
||||
if (!(state.getBlock() instanceof ReFramedBlock)) return state.isOpaque();
|
||||
return true; // forces to compute correct shape
|
||||
}
|
||||
|
||||
@Redirect(
|
||||
method = "isSideExposed",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/block/BlockState;getCullingShape(Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/util/shape/VoxelShape;"
|
||||
)
|
||||
)
|
||||
private VoxelShape isSideShapeExposed(BlockState state, BlockView world, BlockPos pos) {
|
||||
if (!(state.getBlock() instanceof ReFramedBlock block)) return state.getCullingShape(world, pos);
|
||||
return block.getShadingShape(state, world, pos);
|
||||
}
|
||||
|
||||
@Redirect(
|
||||
method = "render",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/fabricmc/fabric/api/client/render/fluid/v1/FluidRenderHandlerRegistry;isBlockTransparent(Lnet/minecraft/block/Block;)Z"
|
||||
)
|
||||
)
|
||||
private boolean getThemeState(FluidRenderHandlerRegistry fluid_handler, Block block, @Local(argsOnly = true) WorldSlice world, @Local(ordinal = 2) BlockPos pos, @Local BlockState state, @Local Direction dir) {
|
||||
if (!(block instanceof ReFramedBlock rfblock && world.getBlockEntity(pos) instanceof ThemeableBlockEntity framed_entity)) return fluid_handler.isBlockTransparent(block);
|
||||
return !VoxelShapes.isSideCovered(VoxelShapes.fullCube(), rfblock.getShadingShape(state, world, pos), dir)
|
||||
&& framed_entity.getThemes().stream()
|
||||
.anyMatch(s -> s.getBlock() instanceof LeavesBlock
|
||||
|| s.getBlock() instanceof TranslucentBlock
|
||||
|| s.getBlock() instanceof AirBlock
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package fr.adrien1106.reframed.mixin.render;
|
||||
|
||||
import fr.adrien1106.reframed.client.util.RenderHelper;
|
||||
import fr.adrien1106.reframed.util.blocks.ThemeableBlockEntity;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.BlockView;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(Block.class)
|
||||
public abstract class BlockMixin {
|
||||
|
||||
@Inject(
|
||||
method = "shouldDrawSide",
|
||||
at = @At("HEAD"),
|
||||
cancellable = true
|
||||
) // serves as a safety sometimes mods implements culling cache and hence will break some injections...
|
||||
private static void shouldDrawSide(BlockState state, BlockView world, BlockPos pos, Direction side, BlockPos other_pos, CallbackInfoReturnable<Boolean> cir) {
|
||||
if (!(world.getBlockEntity(other_pos) instanceof ThemeableBlockEntity)) return;
|
||||
cir.setReturnValue(RenderHelper.shouldDrawSide(state, world, pos, side, other_pos, 0));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package fr.adrien1106.reframed.mixin.render;
|
||||
|
||||
import fr.adrien1106.reframed.block.ReFramedBlock;
|
||||
import fr.adrien1106.reframed.util.blocks.ThemeableBlockEntity;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.client.render.block.FluidRenderer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockRenderView;
|
||||
import net.minecraft.world.BlockView;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(FluidRenderer.class)
|
||||
public abstract class FluidRendererMixin {
|
||||
|
||||
@Inject(
|
||||
method = "isSideCovered(Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/Direction;FLnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Z",
|
||||
at = @At("HEAD"),
|
||||
cancellable = true
|
||||
) // force dynamic water side rendering
|
||||
private static void isSameSideCovered(BlockView world, Direction direction, float height, BlockPos pos, BlockState state, CallbackInfoReturnable<Boolean> cir) {
|
||||
if (!(state.getBlock() instanceof ReFramedBlock block)
|
||||
) return;
|
||||
|
||||
boolean is_covered = VoxelShapes.isSideCovered(
|
||||
VoxelShapes.cuboid(0.0, 0.0, 0.0, 1.0, height, 1.0),
|
||||
block.getShadingShape(state, world, pos),
|
||||
direction
|
||||
);
|
||||
cir.setReturnValue(is_covered);
|
||||
}
|
||||
|
||||
@Redirect(
|
||||
method = "render",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/BlockRenderView;getBlockState(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/block/BlockState;",
|
||||
ordinal = 7
|
||||
)
|
||||
)
|
||||
private BlockState getThemeState(BlockRenderView world, BlockPos pos) {
|
||||
if (!(world.getBlockEntity(pos) instanceof ThemeableBlockEntity framed_entity)) return world.getBlockState(pos);
|
||||
return framed_entity.getThemes().stream()
|
||||
.anyMatch(state -> state.getBlock() instanceof LeavesBlock
|
||||
|| state.getBlock() instanceof TranslucentBlock
|
||||
|| state.getBlock() instanceof AirBlock
|
||||
)
|
||||
? Blocks.GLASS.getDefaultState()
|
||||
: world.getBlockState(pos) ;
|
||||
}
|
||||
}
|
||||
@@ -12,4 +12,6 @@ public class BlockProperties {
|
||||
public static final IntProperty CORNER_FACE = IntProperty.of("face", 0, 2);
|
||||
public static final IntProperty CORNER_FEATURE = IntProperty.of("corner_feature", 0, 1);
|
||||
public static final EnumProperty<StairShape> STAIR_SHAPE = EnumProperty.of("shape", StairShape.class);
|
||||
public static final IntProperty HALF_LAYERS = IntProperty.of("layers", 1, 4);
|
||||
|
||||
}
|
||||
|
||||
@@ -154,4 +154,8 @@ public enum Corner implements StringIdentifiable {
|
||||
third_direction == face ? opposite : third_direction
|
||||
);
|
||||
}
|
||||
|
||||
public Direction getMatchingDirection(Edge edge) {
|
||||
return hasDirection(edge.getSecondDirection()) ? edge.getSecondDirection() : edge.getFirstDirection();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,4 +10,6 @@ public interface ThemeableBlockEntity {
|
||||
void setTheme(BlockState state, int i);
|
||||
|
||||
List<BlockState> getThemes();
|
||||
|
||||
boolean isSolid();
|
||||
}
|
||||
|
||||
@@ -12,10 +12,11 @@ import net.minecraft.util.math.BlockPos;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static fr.adrien1106.reframed.block.ReFramedEntity.BLOCKSTATE_KEY;
|
||||
import static fr.adrien1106.reframed.block.ReFramedEntity.*;
|
||||
|
||||
public class ThemedBlockEntity extends BlockEntity implements ThemeableBlockEntity {
|
||||
private final List<BlockState> themes;
|
||||
private final boolean isSolid;
|
||||
|
||||
public ThemedBlockEntity(NbtCompound compound, BlockPos pos, BlockState state) {
|
||||
super(null, pos, state);
|
||||
@@ -26,6 +27,7 @@ public class ThemedBlockEntity extends BlockEntity implements ThemeableBlockEnti
|
||||
compound.getCompound(BLOCKSTATE_KEY + i)
|
||||
));
|
||||
}
|
||||
isSolid = !compound.contains(BITFIELD_KEY) || (compound.getByte(BITFIELD_KEY) & SOLIDITY_MASK) != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -47,4 +49,9 @@ public class ThemedBlockEntity extends BlockEntity implements ThemeableBlockEnti
|
||||
public List<BlockState> getThemes() {
|
||||
return themes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSolid() {
|
||||
return isSolid;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,27 @@
|
||||
{
|
||||
"credit": "Made with Blockbench",
|
||||
"textures": {
|
||||
"particle": "#side"
|
||||
},
|
||||
"elements": [
|
||||
{
|
||||
"from": [0, 0, 0],
|
||||
"from": [0, 0, 8],
|
||||
"to": [8, 8, 16],
|
||||
"faces": {
|
||||
"north": {"uv": [8, 8, 16, 16], "texture": "#side", "cullface": "north"},
|
||||
"south": {"uv": [0, 8, 8, 16], "texture": "#side", "cullface": "south"},
|
||||
"west": {"uv": [0, 8, 16, 16], "texture": "#side", "cullface": "west"},
|
||||
"up": {"uv": [0, 0, 8, 16], "texture": "#top"},
|
||||
"down": {"uv": [0, 0, 8, 16], "texture": "#bottom", "cullface": "down"}
|
||||
"west": {"uv": [8, 8, 16, 16], "texture": "#side", "cullface": "west"},
|
||||
"up": {"uv": [0, 8, 8, 16], "texture": "#top"},
|
||||
"down": {"uv": [0, 0, 8, 8], "texture": "#bottom", "cullface": "down"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [0, 0, 0],
|
||||
"to": [8, 8, 8],
|
||||
"faces": {
|
||||
"north": {"uv": [8, 8, 16, 16], "texture": "#side", "cullface": "north"},
|
||||
"west": {"uv": [0, 8, 8, 16], "texture": "#side", "cullface": "west"},
|
||||
"up": {"uv": [0, 0, 8, 8], "texture": "#top"},
|
||||
"down": {"uv": [0, 8, 8, 16], "texture": "#bottom", "cullface": "down"}
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1,16 +1,26 @@
|
||||
{
|
||||
"credit": "Made with Blockbench",
|
||||
"textures": {
|
||||
"particle": "#side"
|
||||
},
|
||||
"elements": [
|
||||
{
|
||||
"from": [8, 0, 0],
|
||||
"from": [8, 8, 0],
|
||||
"to": [16, 16, 8],
|
||||
"faces": {
|
||||
"north": {"uv": [0, 0, 8, 16], "texture": "#side", "cullface": "north"},
|
||||
"east": {"uv": [8, 0, 16, 16], "texture": "#side", "cullface": "east"},
|
||||
"west": {"uv": [0, 0, 8, 16], "texture": "#side"},
|
||||
"up": {"uv": [8, 0, 16, 8], "texture": "#top", "cullface": "up"},
|
||||
"north": {"uv": [0, 0, 8, 8], "texture": "#side", "cullface": "north"},
|
||||
"east": {"uv": [8, 0, 16, 8], "texture": "#side", "cullface": "east"},
|
||||
"west": {"uv": [0, 0, 8, 8], "texture": "#side"},
|
||||
"up": {"uv": [8, 0, 16, 8], "texture": "#top", "cullface": "up"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [8, 0, 0],
|
||||
"to": [16, 8, 8],
|
||||
"faces": {
|
||||
"north": {"uv": [0, 8, 8, 16], "texture": "#side", "cullface": "north"},
|
||||
"east": {"uv": [8, 8, 16, 16], "texture": "#side", "cullface": "east"},
|
||||
"west": {"uv": [0, 8, 8, 16], "texture": "#side"},
|
||||
"down": {"uv": [8, 8, 16, 16], "texture": "#bottom", "cullface": "down"}
|
||||
}
|
||||
},
|
||||
@@ -50,7 +60,7 @@
|
||||
"name": "outer_stairs",
|
||||
"origin": [8, 8, 8],
|
||||
"color": 0,
|
||||
"children": [0, 1, 2, 3]
|
||||
"children": [0, 1, 2, 3, 4]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -33,14 +33,17 @@
|
||||
"compat.IndiumNonTerrainBlockRenderContextMixin",
|
||||
"compat.IndiumTerrainRenderContextMixin",
|
||||
"compat.SodiumBlockOcclusionCacheMixin",
|
||||
"compat.SodiumFluidRendererMixin",
|
||||
"model.WeightedBakedModelAccessor",
|
||||
"particles.AccessorParticle",
|
||||
"particles.AccessorSpriteBillboardParticle",
|
||||
"particles.MixinBlockDustParticle",
|
||||
"render.AbstractBlockRenderContextMixin",
|
||||
"render.BlockMixin",
|
||||
"render.BlockModelRendererMixin",
|
||||
"render.BlockRenderContextMixin",
|
||||
"render.BlockRenderInfoMixin",
|
||||
"render.FluidRendererMixin",
|
||||
"render.MultipartBakedModelMixin",
|
||||
"render.TerrainRenderContextMixin",
|
||||
"render.WorldRendererMixin",
|
||||
|
||||
Reference in New Issue
Block a user