Fixed rendering issue.

This commit is contained in:
stfwi 2022-01-18 17:16:55 +01:00
parent 82c2484872
commit d31cedfea1
5 changed files with 16 additions and 13 deletions

View file

@ -24,6 +24,7 @@ import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@ -71,7 +72,7 @@ public class ModRenderers
@OnlyIn(Dist.CLIENT)
public static class CraftingTableTer implements BlockEntityRenderer<EdCraftingTable.CraftingTableTileEntity>
{
private static int tesr_error_counter = 4;
private static int tesr_error_counter = 16;
private static final float scaler = 0.1f;
private static final float gap = 0.19f;
private static final float[] yrotations = {0, 90, 180, 270}; // [hdirection] S-W-N-E
@ -92,7 +93,9 @@ public class ModRenderers
{
if(tesr_error_counter <= 0) return;
try {
final int di = Mth.clamp(te.getLevel().getBlockState(te.getBlockPos()).getValue(CraftingTableBlock.HORIZONTAL_FACING).get2DDataValue(), 0, 3);
final BlockState state = te.getLevel().getBlockState(te.getBlockPos());
if(!(state.getBlock() instanceof EdCraftingTable.CraftingTableBlock)) return;
final int di = Mth.clamp(state.getValue(CraftingTableBlock.HORIZONTAL_FACING).get2DDataValue(), 0, 3);
long posrnd = te.getBlockPos().asLong();
posrnd = (posrnd>>16)^(posrnd<<1);
for(int i=0; i<9; ++i) {
@ -150,7 +153,9 @@ public class ModRenderers
try {
final ItemStack stack = te.getItemFrameStack();
if(stack.isEmpty()) return;
final int di = Mth.clamp(te.getLevel().getBlockState(te.getBlockPos()).getValue(EdLabeledCrate.LabeledCrateBlock.HORIZONTAL_FACING).get2DDataValue(), 0, 3);
final BlockState state = te.getLevel().getBlockState(te.getBlockPos());
if(!(state.getBlock() instanceof EdLabeledCrate.LabeledCrateBlock)) return;
final int di = Mth.clamp(state.getValue(EdLabeledCrate.LabeledCrateBlock.HORIZONTAL_FACING).get2DDataValue(), 0, 3);
double ox = tr[di][0], oy = tr[di][1], oz = tr[di][2];
float ry = (float)tr[di][3];
mxs.pushPose();

View file

@ -209,12 +209,7 @@ public class StandardBlocks
{ this(conf, properties, Arrays.stream(aabbs).map(Shapes::create).reduce(Shapes.empty(), (shape, aabb)->Shapes.joinUnoptimized(shape, aabb, BooleanOp.OR))); }
public Cutout(long conf, BlockBehaviour.Properties properties, VoxelShape voxel_shape)
{
super(conf, properties);
vshape = voxel_shape;
BlockState state = getStateDefinition().any();
registerDefaultState(state);
}
{ super(conf, properties); vshape = voxel_shape; }
@Override
@SuppressWarnings("deprecation")
@ -304,7 +299,7 @@ public class StandardBlocks
public Directed(long config, BlockBehaviour.Properties properties, final Function<List<BlockState>, Map<BlockState,VoxelShape>> shape_supplier)
{
super(config, properties);
registerDefaultState(stateDefinition.any().setValue(FACING, Direction.UP));
registerDefaultState(super.defaultBlockState().setValue(FACING, Direction.UP));
vshapes = shape_supplier.apply(getStateDefinition().getPossibleStates());
}
@ -459,7 +454,7 @@ public class StandardBlocks
public Horizontal(long config, BlockBehaviour.Properties properties, final Function<List<BlockState>, Map<BlockState,VoxelShape>> shape_supplier)
{
super(config|CFG_HORIZIONTAL, properties);
registerDefaultState(stateDefinition.any().setValue(HORIZONTAL_FACING, Direction.NORTH));
registerDefaultState(super.defaultBlockState().setValue(HORIZONTAL_FACING, Direction.NORTH));
vshapes = shape_supplier.apply(getStateDefinition().getPossibleStates());
cshapes = shape_supplier.apply(getStateDefinition().getPossibleStates());
}