Merge branch 'The-Vowels/mc1.18/dev' into mc1.18/dev

# Conflicts:
#	src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java
#	src/main/java/com/simibubi/create/foundation/utility/worldWrappers/PlacementSimulationWorld.java
#	src/main/java/com/simibubi/create/foundation/utility/worldWrappers/chunk/WrappedChunk.java
This commit is contained in:
Jozufozu 2021-12-26 13:27:26 -08:00
commit 150158d7be
5 changed files with 74 additions and 3 deletions

View File

@ -19,7 +19,7 @@ parchment_version = 2021.12.19
# dependency versions
registrate_version = MC1.18-1.0.21
flywheel_version = 1.18-0.5.0.30
flywheel_version = 1.18-0.5.0.31
jei_minecraft_version = 1.18
jei_version = 9.0.0.40

View File

@ -38,4 +38,14 @@ public enum Mods {
return Optional.of(toRun.get().get());
return Optional.empty();
}
/**
* Simple hook to execute code if a mod is installed
* @param toExecute will be executed only if the mod is loaded
*/
public void executeIfInstalled(Supplier<Runnable> toExecute) {
if (isLoaded()) {
toExecute.get().run();
}
}
}

View File

@ -21,7 +21,6 @@ public class ContraptionWorld extends WrappedWorld {
this.contraption = contraption;
}
@Override
public BlockState getBlockState(BlockPos pos) {
StructureTemplate.StructureBlockInfo blockInfo = contraption.getBlocks().get(pos);
@ -46,4 +45,16 @@ public class ContraptionWorld extends WrappedWorld {
public void playLocalSound(double x, double y, double z, SoundEvent p_184134_7_, SoundSource p_184134_8_, float p_184134_9_, float p_184134_10_, boolean p_184134_11_) {
world.playLocalSound(x, y, z, p_184134_7_, p_184134_8_, p_184134_9_, p_184134_10_, p_184134_11_);
}
// Calculate lazily to avoid issues on load when the bounds are yet to be determined.
@Override
public int getHeight() {
return getMinBuildHeight() * (-2);
}
@Override
public int getMinBuildHeight() {
return - (int) contraption.bounds.getYsize() + 1;
}
}

View File

@ -19,6 +19,7 @@ import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.AllMovementBehaviours;
import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity;
import com.simibubi.create.content.contraptions.components.structureMovement.Contraption;
import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionWorld;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
import com.simibubi.create.foundation.render.SuperByteBuffer;
@ -104,7 +105,8 @@ public class ContraptionRenderDispatcher {
}
public static VirtualRenderWorld setupRenderWorld(Level world, Contraption c) {
VirtualRenderWorld renderWorld = new VirtualRenderWorld(world);
ContraptionWorld contraptionWorld = c.getContraptionWorld();
VirtualRenderWorld renderWorld = new VirtualRenderWorld(world, contraptionWorld.getHeight(), contraptionWorld.getMinBuildHeight());
renderWorld.setTileEntities(c.presentTileEntities.values());

View File

@ -9,6 +9,7 @@ import javax.annotation.Nullable;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.RegistryAccess;
import net.minecraft.core.SectionPos;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundSource;
import net.minecraft.tags.TagContainer;
@ -198,4 +199,51 @@ public class WrappedWorld extends Level {
protected LevelEntityGetter<Entity> getEntities() {
return entityGetter;
}
// Intentionally copied from LevelHeightAccessor. Lithium overrides these methods so we need to, too.
@Override
public int getMaxBuildHeight() {
return this.getMinBuildHeight() + this.getHeight();
}
@Override
public int getSectionsCount() {
return this.getMaxSection() - this.getMinSection();
}
@Override
public int getMinSection() {
return SectionPos.blockToSectionCoord(this.getMinBuildHeight());
}
@Override
public int getMaxSection() {
return SectionPos.blockToSectionCoord(this.getMaxBuildHeight() - 1) + 1;
}
@Override
public boolean isOutsideBuildHeight(BlockPos pos) {
return this.isOutsideBuildHeight(pos.getY());
}
@Override
public boolean isOutsideBuildHeight(int y) {
return y < this.getMinBuildHeight() || y >= this.getMaxBuildHeight();
}
@Override
public int getSectionIndex(int y) {
return this.getSectionIndexFromSectionY(SectionPos.blockToSectionCoord(y));
}
@Override
public int getSectionIndexFromSectionY(int sectionY) {
return sectionY - this.getMinSection();
}
@Override
public int getSectionYFromSectionIndex(int sectionIndex) {
return sectionIndex + this.getMinSection();
}
}