mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-14 23:53:42 +01:00
Fix crash rendering biome-tinted blocks on contraptions
- Biome colors now line up with the world
This commit is contained in:
parent
0ff67382ee
commit
e6914b1a6f
3 changed files with 18 additions and 7 deletions
|
@ -19,7 +19,7 @@ parchment_version = 2021.12.19
|
|||
|
||||
# dependency versions
|
||||
registrate_version = MC1.18-1.0.21
|
||||
flywheel_version = 1.18-0.5.1.40
|
||||
flywheel_version = 1.18-0.5.1.42
|
||||
jei_minecraft_version = 1.18
|
||||
jei_version = 9.0.0.40
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld;
|
|||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
|
@ -14,14 +15,24 @@ import net.minecraft.world.phys.Vec3;
|
|||
|
||||
public class ContraptionWorld extends WrappedWorld {
|
||||
final Contraption contraption;
|
||||
private final int minY;
|
||||
private final int height;
|
||||
|
||||
public ContraptionWorld(Level world, Contraption contraption) {
|
||||
public ContraptionWorld(Level world, Contraption contraption) {
|
||||
super(world);
|
||||
|
||||
this.contraption = contraption;
|
||||
}
|
||||
|
||||
@Override
|
||||
minY = nextMultipleOf16(contraption.bounds.minY);
|
||||
height = nextMultipleOf16(contraption.bounds.maxY) - minY;
|
||||
}
|
||||
|
||||
// https://math.stackexchange.com/questions/291468
|
||||
private static int nextMultipleOf16(double a) {
|
||||
return (((Math.abs((int) a) - 1) | 15) + 1) * Mth.sign(a);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlockState(BlockPos pos) {
|
||||
StructureTemplate.StructureBlockInfo blockInfo = contraption.getBlocks().get(pos);
|
||||
|
||||
|
@ -51,11 +62,11 @@ public class ContraptionWorld extends WrappedWorld {
|
|||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return getMinBuildHeight() * (-2);
|
||||
return height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinBuildHeight() {
|
||||
return - (int) contraption.bounds.getYsize();
|
||||
return minY;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ public class ContraptionRenderDispatcher {
|
|||
|
||||
public static VirtualRenderWorld setupRenderWorld(Level world, Contraption c) {
|
||||
ContraptionWorld contraptionWorld = c.getContraptionWorld();
|
||||
VirtualRenderWorld renderWorld = new VirtualRenderWorld(world, contraptionWorld.getHeight(), contraptionWorld.getMinBuildHeight());
|
||||
VirtualRenderWorld renderWorld = new VirtualRenderWorld(world, c.anchor, contraptionWorld.getHeight(), contraptionWorld.getMinBuildHeight());
|
||||
|
||||
renderWorld.setBlockEntities(c.presentTileEntities.values());
|
||||
|
||||
|
|
Loading…
Reference in a new issue