Revert "Don't crash with starlight"

This reverts commit 4ae1ce3d
This commit is contained in:
JozsefA 2021-04-09 16:20:17 -07:00
parent 536b8d2d5e
commit cbb7e48565
9 changed files with 9 additions and 178 deletions

View file

@ -39,8 +39,7 @@ minecraft {
workingDirectory project.file('run') workingDirectory project.file('run')
// property 'mixin.env.disableRefMap', 'true' // property 'mixin.env.disableRefMap', 'true'
arg '-mixin.config=create.mixins.json' arg '-mixin.config=create.mixins.json'
//jvmArgs '-XX:+UnlockCommercialFeatures' jvmArgs '-XX:+UnlockCommercialFeatures'
jvmArgs '-Dmixin.env.disableRefMap=true'
property 'forge.logging.console.level', 'info' property 'forge.logging.console.level', 'info'
property 'fml.earlyprogresswindow', 'false' property 'fml.earlyprogresswindow', 'false'
mods { mods {
@ -110,10 +109,6 @@ repositories {
maven { maven {
url = "https://www.cursemaven.com" url = "https://www.cursemaven.com"
} }
flatDir {
dirs 'deps'
}
} }
configurations { configurations {
@ -140,9 +135,6 @@ dependencies {
// runtimeOnly fg.deobf("slimeknights.mantle:Mantle:1.16.3-1.6.40") // runtimeOnly fg.deobf("slimeknights.mantle:Mantle:1.16.3-1.6.40")
// runtimeOnly fg.deobf("slimeknights.tconstruct:TConstruct:1.16.3-3.0.1.24") // runtimeOnly fg.deobf("slimeknights.tconstruct:TConstruct:1.16.3-3.0.1.24")
compileOnly fg.deobf("local:starlight-1.0.0-RC1")
//runtimeOnly fg.deobf("local:starlight-1.0.0-RC1")
annotationProcessor 'org.spongepowered:mixin:0.8:processor' annotationProcessor 'org.spongepowered:mixin:0.8:processor'
} }

Binary file not shown.

View file

@ -16,7 +16,6 @@ import com.simibubi.create.foundation.render.backend.instancing.IInstanceRendere
import com.simibubi.create.foundation.render.backend.light.GridAlignedBB; import com.simibubi.create.foundation.render.backend.light.GridAlignedBB;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld; import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorldStarlight;
import net.minecraft.block.BlockRenderType; import net.minecraft.block.BlockRenderType;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
@ -40,7 +39,6 @@ import net.minecraft.world.gen.feature.template.Template;
import net.minecraft.world.lighting.WorldLightManager; import net.minecraft.world.lighting.WorldLightManager;
import net.minecraftforge.client.ForgeHooksClient; import net.minecraftforge.client.ForgeHooksClient;
import net.minecraftforge.client.model.data.EmptyModelData; import net.minecraftforge.client.model.data.EmptyModelData;
import net.minecraftforge.fml.ModList;
public class RenderedContraption { public class RenderedContraption {
private final HashMap<RenderType, ContraptionModel> renderLayers = new HashMap<>(); private final HashMap<RenderType, ContraptionModel> renderLayers = new HashMap<>();
@ -172,14 +170,6 @@ public class RenderedContraption {
} }
private static PlacementSimulationWorld setupRenderWorld(World world, Contraption c) { private static PlacementSimulationWorld setupRenderWorld(World world, Contraption c) {
if (ModList.get().isLoaded("starlight")) {
return PlacementSimulationWorldStarlight.setupRenderWorldStarlight(world, c);
} else {
return setupRenderWorldVanilla(world, c);
}
}
private static PlacementSimulationWorld setupRenderWorldVanilla(World world, Contraption c) {
PlacementSimulationWorld renderWorld = new PlacementSimulationWorld(world); PlacementSimulationWorld renderWorld = new PlacementSimulationWorld(world);
renderWorld.setTileEntities(c.presentTileEntities.values()); renderWorld.setTileEntities(c.presentTileEntities.values());

View file

@ -12,7 +12,6 @@ import java.util.stream.Stream;
import com.simibubi.create.Create; import com.simibubi.create.Create;
import com.simibubi.create.foundation.utility.worldWrappers.WrappedChunkProvider; import com.simibubi.create.foundation.utility.worldWrappers.WrappedChunkProvider;
import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld; import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld;
import com.simibubi.create.foundation.utility.worldWrappers.chunk.WrappedChunk;
import net.minecraft.block.AbstractFurnaceBlock; import net.minecraft.block.AbstractFurnaceBlock;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@ -54,7 +53,7 @@ public class SchematicWorld extends WrappedWorld implements IServerWorld {
} }
public SchematicWorld(BlockPos anchor, World original) { public SchematicWorld(BlockPos anchor, World original) {
super(original, new WrappedChunkProvider(WrappedChunk::new)); super(original, new WrappedChunkProvider());
this.blocks = new HashMap<>(); this.blocks = new HashMap<>();
this.tileEntities = new HashMap<>(); this.tileEntities = new HashMap<>();
this.bounds = new MutableBoundingBox(); this.bounds = new MutableBoundingBox();

View file

@ -6,7 +6,6 @@ import java.util.HashSet;
import java.util.function.Predicate; import java.util.function.Predicate;
import com.simibubi.create.foundation.render.backend.instancing.IFlywheelWorld; import com.simibubi.create.foundation.render.backend.instancing.IFlywheelWorld;
import com.simibubi.create.foundation.utility.worldWrappers.chunk.WrappedChunk;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
@ -26,7 +25,7 @@ public class PlacementSimulationWorld extends WrappedWorld implements IFlywheelW
private final BlockPos.Mutable scratch = new BlockPos.Mutable(); private final BlockPos.Mutable scratch = new BlockPos.Mutable();
public PlacementSimulationWorld(World wrapped) { public PlacementSimulationWorld(World wrapped) {
this(wrapped, new WrappedChunkProvider(WrappedChunk::new)); this(wrapped, new WrappedChunkProvider());
} }
public PlacementSimulationWorld(World wrapped, WrappedChunkProvider chunkProvider) { public PlacementSimulationWorld(World wrapped, WrappedChunkProvider chunkProvider) {

View file

@ -1,60 +0,0 @@
package com.simibubi.create.foundation.utility.worldWrappers;
import com.simibubi.create.content.contraptions.components.structureMovement.Contraption;
import com.simibubi.create.foundation.utility.worldWrappers.chunk.WrappedChunkStarlight;
import ca.spottedleaf.starlight.common.light.VariableBlockLightHandler;
import ca.spottedleaf.starlight.common.light.VariableBlockLightHandlerImpl;
import ca.spottedleaf.starlight.common.world.ExtendedWorld;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.IChunk;
import net.minecraft.world.gen.feature.template.Template;
import net.minecraft.world.lighting.WorldLightManager;
public class PlacementSimulationWorldStarlight extends PlacementSimulationWorld implements ExtendedWorld {
VariableBlockLightHandler variableBlockLightHandler = new VariableBlockLightHandlerImpl();
public PlacementSimulationWorldStarlight(World wrapped) {
super(wrapped, new WrappedChunkProvider(WrappedChunkStarlight::new));
}
@Override
public Chunk getChunkAtImmediately(int i, int i1) {
return null;
}
@Override
public IChunk getAnyChunkImmediately(int i, int i1) {
return null;
}
@Override
public VariableBlockLightHandler getCustomLightHandler() {
return variableBlockLightHandler;
}
@Override
public void setCustomLightHandler(VariableBlockLightHandler variableBlockLightHandler) {
this.variableBlockLightHandler = variableBlockLightHandler;
}
public static PlacementSimulationWorld setupRenderWorldStarlight(World world, Contraption c) {
PlacementSimulationWorld renderWorld = new PlacementSimulationWorldStarlight(world);
renderWorld.setTileEntities(c.presentTileEntities.values());
for (Template.BlockInfo info : c.getBlocks()
.values())
renderWorld.setBlockState(info.pos, info.state);
WorldLightManager lighter = renderWorld.lighter;
renderWorld.chunkProvider.getLightSources().forEach((pos) -> lighter.func_215573_a(pos, renderWorld.getLightValue(pos)));
lighter.tick(Integer.MAX_VALUE, true, false);
return renderWorld;
}
}

View file

@ -21,12 +21,6 @@ public class WrappedChunkProvider extends AbstractChunkProvider {
public HashMap<Long, WrappedChunk> chunks; public HashMap<Long, WrappedChunk> chunks;
protected final ChunkFactory chunkFactory;
public WrappedChunkProvider(ChunkFactory chunkFactory) {
this.chunkFactory = chunkFactory;
}
public WrappedChunkProvider setWorld(PlacementSimulationWorld world) { public WrappedChunkProvider setWorld(PlacementSimulationWorld world) {
this.world = world; this.world = world;
this.chunks = new HashMap<>(); this.chunks = new HashMap<>();
@ -64,8 +58,7 @@ public class WrappedChunkProvider extends AbstractChunkProvider {
if (chunks == null) if (chunks == null)
return null; return null;
return chunks.computeIfAbsent(pos, $ -> new WrappedChunk(world, x, z));
return chunks.computeIfAbsent(pos, $ -> chunkFactory.create(world, x, z));
} }
@Override @Override
@ -77,8 +70,4 @@ public class WrappedChunkProvider extends AbstractChunkProvider {
public WorldLightManager getLightManager() { public WorldLightManager getLightManager() {
return world.getLightingProvider(); return world.getLightingProvider();
} }
public interface ChunkFactory {
WrappedChunk create(PlacementSimulationWorld world, int x, int z);
}
} }

View file

@ -257,5 +257,4 @@ public class WrappedChunk implements IChunk {
return null; return null;
} }
} }

View file

@ -1,77 +0,0 @@
package com.simibubi.create.foundation.utility.worldWrappers.chunk;
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
import ca.spottedleaf.starlight.common.chunk.ExtendedChunk;
import ca.spottedleaf.starlight.common.light.SWMRNibbleArray;
import ca.spottedleaf.starlight.common.light.StarLightEngine;
import net.minecraft.world.chunk.ChunkSection;
import net.minecraft.world.chunk.IChunk;
public class WrappedChunkStarlight extends WrappedChunk implements ExtendedChunk {
private SWMRNibbleArray[] blockNibbles;
private SWMRNibbleArray[] skyNibbles;
private boolean[] skyEmptinessMap;
private boolean[] blockEmptinessMap;
public WrappedChunkStarlight(PlacementSimulationWorld world, int x, int z) {
super(world, x, z);
this.blockNibbles = StarLightEngine.getFilledEmptyLight(world);
this.skyNibbles = StarLightEngine.getFilledEmptyLight(world);
this.skyEmptinessMap = getEmptySectionsForChunk(this);
this.blockEmptinessMap = getEmptySectionsForChunk(this);
}
@Override
public SWMRNibbleArray[] getBlockNibbles() {
return blockNibbles;
}
@Override
public void setBlockNibbles(SWMRNibbleArray[] swmrNibbleArrays) {
this.blockNibbles = swmrNibbleArrays;
}
@Override
public SWMRNibbleArray[] getSkyNibbles() {
return skyNibbles;
}
@Override
public void setSkyNibbles(SWMRNibbleArray[] swmrNibbleArrays) {
this.skyNibbles = swmrNibbleArrays;
}
@Override
public boolean[] getSkyEmptinessMap() {
return skyEmptinessMap;
}
@Override
public void setSkyEmptinessMap(boolean[] booleans) {
this.skyEmptinessMap = booleans;
}
@Override
public boolean[] getBlockEmptinessMap() {
return blockEmptinessMap;
}
@Override
public void setBlockEmptinessMap(boolean[] booleans) {
this.blockEmptinessMap = booleans;
}
public static boolean[] getEmptySectionsForChunk(IChunk chunk) {
ChunkSection[] sections = chunk.getSections();
boolean[] ret = new boolean[sections.length];
for (int i = 0; i < sections.length; ++i) {
ret[i] = sections[i] == null || sections[i].isEmpty();
}
return ret;
}
}