This commit is contained in:
gnembon committed 2020-07-15 04:35:15 -03:00
1 parent b6543ff8dd
commit 3b90bd5d3a
12 files changed
+48 -48

No files matched your search

+2 -2
View File
@@ -5,8 +5,8 @@ org.gradle.jvmargs=-Xmx1G
# check these on https://fabricmc.net/use # check these on https://fabricmc.net/use
# or better: https://modmuss50.me/fabric.html # or better: https://modmuss50.me/fabric.html
minecraft_version=20w28a minecraft_version=20w28a
yarn_mappings=20w28a+build.17 yarn_mappings=20w28a+build.22
loader_version=0.8.9+build.203 loader_version=0.9.0+build.204
# Mod Properties # Mod Properties
mod_version = 1.4.2+v200712 mod_version = 1.4.2+v200712
@@ -4,5 +4,5 @@ import net.minecraft.world.chunk.ChunkNibbleArray;
public interface ChunkLightProviderInterface public interface ChunkLightProviderInterface
{ {
int callGetCurrentLevelFromArray(ChunkNibbleArray array, long blockPos); int callGetCurrentLevelFromSection(ChunkNibbleArray array, long blockPos);
} }
@@ -167,7 +167,7 @@ public class FeatureGenerator
if (!computeBox) return StructureStart.DEFAULT; if (!computeBox) return StructureStart.DEFAULT;
StructureManager manager = world.getStructureManager(); StructureManager manager = world.getStructureManager();
StructureStart<T> structureStart3 = structure.getStructureStartFactory().create((StructureFeature<T>) configuredFeature.feature, chunkPos.x, chunkPos.z, BlockBox.empty(), 0, seed); StructureStart<T> structureStart3 = structure.getStructureStartFactory().create((StructureFeature<T>) configuredFeature.feature, chunkPos.x, chunkPos.z, BlockBox.empty(), 0, seed);
structureStart3.init(world.method_30349(), generator, manager, chunkPos.x, chunkPos.z, biome, (T) configuredFeature.config); structureStart3.init(world.getRegistryManager(), generator, manager, chunkPos.x, chunkPos.z, biome, (T) configuredFeature.config);
if (!structureStart3.hasChildren()) return null; if (!structureStart3.hasChildren()) return null;
return structureStart3; return structureStart3;
} }
@@ -31,14 +31,14 @@ public abstract class BlockLightStorage_scarpetChunkCreationMixin extends LightS
for (int y = -1; y < 17; ++y) for (int y = -1; y < 17; ++y)
{ {
final long sectionPos = ChunkSectionPos.asLong(ChunkSectionPos.getX(cPos), y, ChunkSectionPos.getZ(cPos)); final long sectionPos = ChunkSectionPos.asLong(ChunkSectionPos.getX(cPos), y, ChunkSectionPos.getZ(cPos));
final long pos = BlockPos.asLong(ChunkSectionPos.getWorldCoord(ChunkSectionPos.getX(sectionPos)), ChunkSectionPos.getWorldCoord(y), ChunkSectionPos.getWorldCoord(ChunkSectionPos.getZ(sectionPos))); final long pos = BlockPos.asLong(ChunkSectionPos.getBlockCoord(ChunkSectionPos.getX(sectionPos)), ChunkSectionPos.getBlockCoord(y), ChunkSectionPos.getBlockCoord(ChunkSectionPos.getZ(sectionPos)));
if (!this.hasLight(sectionPos)) if (!this.hasSection(sectionPos))
continue; continue;
for (final Direction dir : Direction.Type.HORIZONTAL) for (final Direction dir : Direction.Type.HORIZONTAL)
{ {
final ChunkNibbleArray neighborLightArray = this.getLightArray(ChunkSectionPos.offset(sectionPos, dir)); final ChunkNibbleArray neighborLightArray = this.getLightSection(ChunkSectionPos.offset(sectionPos, dir));
if (neighborLightArray == null) if (neighborLightArray == null)
continue; continue;
@@ -55,7 +55,7 @@ public abstract class BlockLightStorage_scarpetChunkCreationMixin extends LightS
final long dst = BlockPos.add(pos, ox + t * dx, dy, oz + t * dz); final long dst = BlockPos.add(pos, ox + t * dx, dy, oz + t * dz);
final long src = BlockPos.offset(dst, dir); final long src = BlockPos.offset(dst, dir);
final int srcLevel = ((ChunkLightProviderInterface) lightProvider).callGetCurrentLevelFromArray(neighborLightArray, src); final int srcLevel = ((ChunkLightProviderInterface) lightProvider).callGetCurrentLevelFromSection(neighborLightArray, src);
levelPropagator.invokeUpdateLevel(src, dst, levelPropagator.callGetPropagatedLevel(src, dst, srcLevel), true); levelPropagator.invokeUpdateLevel(src, dst, levelPropagator.callGetPropagatedLevel(src, dst, srcLevel), true);
} }
@@ -31,6 +31,6 @@ public abstract class ChunkLightProvider_scarpetChunkCreationMixin implements Li
} }
@Override @Override
@Invoker("getCurrentLevelFromArray") @Invoker("getCurrentLevelFromSection")
public abstract int callGetCurrentLevelFromArray(ChunkNibbleArray array, long blockPos); public abstract int callGetCurrentLevelFromSection(ChunkNibbleArray array, long blockPos);
} }
@@ -24,26 +24,26 @@ import net.minecraft.world.chunk.light.LightStorage;
public abstract class LightStorage_scarpetChunkCreationMixin implements LightStorageInterface public abstract class LightStorage_scarpetChunkCreationMixin implements LightStorageInterface
{ {
@Shadow @Shadow
protected abstract ChunkNibbleArray getLightArray(final long sectionPos, final boolean cached); protected abstract ChunkNibbleArray getLightSection(final long sectionPos, final boolean cached);
@Shadow @Shadow
protected abstract void removeChunkData(final ChunkLightProvider<?, ?> storage, final long blockChunkPos); protected abstract void removeSection(final ChunkLightProvider<?, ?> storage, final long blockChunkPos);
@Shadow @Shadow
@Final @Final
protected LongSet field_15802; protected LongSet dirtySections;
@Shadow @Shadow
@Final @Final
protected ChunkToNibbleArrayMap<?> lightArrays; protected ChunkToNibbleArrayMap<?> storage;
@Shadow protected abstract boolean hasLight(final long sectionPos); @Shadow protected abstract boolean hasSection(final long sectionPos);
@Shadow @Shadow
@Final @Final
protected Long2ObjectMap<ChunkNibbleArray> lightArraysToAdd; protected Long2ObjectMap<ChunkNibbleArray> queuedSections;
@Shadow protected abstract void setLightEnabled(final long l, final boolean bl); @Shadow protected abstract void setColumnEnabled(final long l, final boolean bl);
@Unique @Unique
private final LongSet removedChunks = new LongOpenHashSet(); private final LongSet removedChunks = new LongOpenHashSet();
@@ -64,7 +64,7 @@ public abstract class LightStorage_scarpetChunkCreationMixin implements LightSto
} }
@Inject( @Inject(
method = "updateLightArrays(Lnet/minecraft/world/chunk/light/ChunkLightProvider;ZZ)V", method = "updateLight(Lnet/minecraft/world/chunk/light/ChunkLightProvider;ZZ)V",
at = @At("HEAD") at = @At("HEAD")
) )
private void processData(final ChunkLightProvider<?, ?> lightProvider, final boolean doSkylight, final boolean skipEdgeLightPropagation, final CallbackInfo ci) private void processData(final ChunkLightProvider<?, ?> lightProvider, final boolean doSkylight, final boolean skipEdgeLightPropagation, final CallbackInfo ci)
@@ -77,16 +77,16 @@ public abstract class LightStorage_scarpetChunkCreationMixin implements LightSto
{ {
final long sectionPos = ChunkSectionPos.asLong(ChunkSectionPos.getX(cPos), y, ChunkSectionPos.getZ(cPos)); final long sectionPos = ChunkSectionPos.asLong(ChunkSectionPos.getX(cPos), y, ChunkSectionPos.getZ(cPos));
this.lightArraysToAdd.remove(sectionPos); this.queuedSections.remove(sectionPos);
if (this.hasLight(sectionPos)) if (this.hasSection(sectionPos))
{ {
this.removeChunkData(lightProvider, sectionPos); this.removeSection(lightProvider, sectionPos);
if (this.field_15802.add(sectionPos)) if (this.dirtySections.add(sectionPos))
this.lightArrays.replaceWithCopy(sectionPos); this.storage.replaceWithCopy(sectionPos);
Arrays.fill(this.getLightArray(sectionPos, true).asByteArray(), (byte) 0); Arrays.fill(this.getLightSection(sectionPos, true).asByteArray(), (byte) 0);
} }
} }
@@ -47,7 +47,7 @@ public abstract class ServerLightingProvider_scarpetChunkCreationMixin extends L
chunk.setLightOn(false); chunk.setLightOn(false);
this.enqueue(pos.x, pos.z, () -> 0, ServerLightingProvider.Stage.PRE_UPDATE, Util.debugRunnable(() -> { this.enqueue(pos.x, pos.z, () -> 0, ServerLightingProvider.Stage.PRE_UPDATE, Util.debugRunnable(() -> {
super.setLightEnabled(pos, false); super.setColumnEnabled(pos, false);
((Lighting_scarpetChunkCreationInterface) this).removeLightData(ChunkSectionPos.withZeroZ(ChunkSectionPos.asLong(pos.x, 0, pos.z))); ((Lighting_scarpetChunkCreationInterface) this).removeLightData(ChunkSectionPos.withZeroZ(ChunkSectionPos.asLong(pos.x, 0, pos.z)));
}, },
() -> "Remove light data " + pos () -> "Remove light data " + pos
@@ -60,7 +60,7 @@ public abstract class ServerLightingProvider_scarpetChunkCreationMixin extends L
final ChunkPos pos = chunk.getPos(); final ChunkPos pos = chunk.getPos();
this.enqueue(pos.x, pos.z, () -> 0, ServerLightingProvider.Stage.PRE_UPDATE, Util.debugRunnable(() -> { this.enqueue(pos.x, pos.z, () -> 0, ServerLightingProvider.Stage.PRE_UPDATE, Util.debugRunnable(() -> {
super.setLightEnabled(pos, true); super.setColumnEnabled(pos, true);
chunk.getLightSourcesStream().forEach( chunk.getLightSourcesStream().forEach(
blockPos -> super.addLightSource(blockPos, chunk.getLuminance(blockPos)) blockPos -> super.addLightSource(blockPos, chunk.getLuminance(blockPos))
@@ -38,14 +38,14 @@ public abstract class ServerLightingProvider_scarpetMixin extends LightingProvid
//ChunkPos pos = new ChunkPos(x, z); //ChunkPos pos = new ChunkPos(x, z);
int j; int j;
for(j = -1; j < 17; ++j) { // skip some recomp for(j = -1; j < 17; ++j) { // skip some recomp
super.queueData(LightType.BLOCK, ChunkSectionPos.from(pos, j), new ChunkNibbleArray(), false); super.enqueueSectionData(LightType.BLOCK, ChunkSectionPos.from(pos, j), new ChunkNibbleArray(), false);
super.queueData(LightType.SKY, ChunkSectionPos.from(pos, j), new ChunkNibbleArray(), false); super.enqueueSectionData(LightType.SKY, ChunkSectionPos.from(pos, j), new ChunkNibbleArray(), false);
} }
for(j = 0; j < 16; ++j) { for(j = 0; j < 16; ++j) {
super.updateSectionStatus(ChunkSectionPos.from(pos, j), true); super.setSectionStatus(ChunkSectionPos.from(pos, j), true);
} }
super.setLightEnabled(pos, true); super.setColumnEnabled(pos, true);
chunk.getLightSourcesStream().forEach((blockPos) -> { chunk.getLightSourcesStream().forEach((blockPos) -> {
super.addLightSource(blockPos, chunk.getLuminance(blockPos)); super.addLightSource(blockPos, chunk.getLuminance(blockPos));
@@ -28,19 +28,19 @@ public abstract class SkyLightStorage_scarpetChunkCreationMixin extends LightSto
@Shadow @Shadow
@Final @Final
private LongSet pendingSkylightUpdates; private LongSet sectionsToUpdate;
@Shadow @Shadow
@Final @Final
private LongSet field_15816; private LongSet sectionsToRemove;
@Shadow @Shadow
@Final @Final
private LongSet field_15820; private LongSet field_15820;
@Shadow protected abstract boolean isAboveTopmostLightArray(final long pos); @Shadow protected abstract boolean isAtOrAboveTopmostSection(final long pos);
@Shadow protected abstract boolean isLightEnabled(final long sectionPos); @Shadow protected abstract boolean isSectionEnabled(final long sectionPos);
@Override @Override
public void processRemoveLightData(final long cPos) public void processRemoveLightData(final long cPos)
@@ -49,8 +49,8 @@ public abstract class SkyLightStorage_scarpetChunkCreationMixin extends LightSto
{ {
final long sectionPos = ChunkSectionPos.asLong(ChunkSectionPos.getX(cPos), y, ChunkSectionPos.getZ(cPos)); final long sectionPos = ChunkSectionPos.asLong(ChunkSectionPos.getX(cPos), y, ChunkSectionPos.getZ(cPos));
this.pendingSkylightUpdates.remove(sectionPos); this.sectionsToUpdate.remove(sectionPos);
this.field_15816.remove(sectionPos); this.sectionsToRemove.remove(sectionPos);
this.field_15820.remove(sectionPos); this.field_15820.remove(sectionPos);
} }
@@ -64,22 +64,22 @@ public abstract class SkyLightStorage_scarpetChunkCreationMixin extends LightSto
for (int y = -1; y < 17; ++y) for (int y = -1; y < 17; ++y)
{ {
final long sectionPos = ChunkSectionPos.asLong(ChunkSectionPos.getX(cPos), y, ChunkSectionPos.getZ(cPos)); final long sectionPos = ChunkSectionPos.asLong(ChunkSectionPos.getX(cPos), y, ChunkSectionPos.getZ(cPos));
final long pos = BlockPos.asLong(ChunkSectionPos.getWorldCoord(ChunkSectionPos.getX(sectionPos)), ChunkSectionPos.getWorldCoord(y), ChunkSectionPos.getWorldCoord(ChunkSectionPos.getZ(sectionPos))); final long pos = BlockPos.asLong(ChunkSectionPos.getBlockCoord(ChunkSectionPos.getX(sectionPos)), ChunkSectionPos.getBlockCoord(y), ChunkSectionPos.getBlockCoord(ChunkSectionPos.getZ(sectionPos)));
if (!this.hasLight(sectionPos)) if (!this.hasSection(sectionPos))
continue; continue;
for (final Direction dir : Direction.Type.HORIZONTAL) for (final Direction dir : Direction.Type.HORIZONTAL)
{ {
long neighborCeilingSectionPos = ChunkSectionPos.offset(sectionPos, dir); long neighborCeilingSectionPos = ChunkSectionPos.offset(sectionPos, dir);
final ChunkNibbleArray neighborLightArray = this.getLightArray(neighborCeilingSectionPos); final ChunkNibbleArray neighborLightArray = this.getLightSection(neighborCeilingSectionPos);
ChunkNibbleArray neighborCeilingLightArray = neighborLightArray; ChunkNibbleArray neighborCeilingLightArray = neighborLightArray;
while (neighborCeilingLightArray == null && !this.isAboveTopmostLightArray(neighborCeilingSectionPos)) while (neighborCeilingLightArray == null && !this.isAtOrAboveTopmostSection(neighborCeilingSectionPos))
{ {
neighborCeilingSectionPos = ChunkSectionPos.offset(neighborCeilingSectionPos, Direction.UP); neighborCeilingSectionPos = ChunkSectionPos.offset(neighborCeilingSectionPos, Direction.UP);
neighborCeilingLightArray = this.getLightArray(neighborCeilingSectionPos); neighborCeilingLightArray = this.getLightSection(neighborCeilingSectionPos);
} }
final int ox = 15 * Math.max(dir.getOffsetX(), 0); final int ox = 15 * Math.max(dir.getOffsetX(), 0);
@@ -95,11 +95,11 @@ public abstract class SkyLightStorage_scarpetChunkCreationMixin extends LightSto
long src = BlockPos.offset(dst, dir); long src = BlockPos.offset(dst, dir);
if (neighborLightArray == null) if (neighborLightArray == null)
src = BlockPos.asLong(BlockPos.unpackLongX(src), ChunkSectionPos.getWorldCoord(ChunkSectionPos.getY(neighborCeilingSectionPos)), BlockPos.unpackLongZ(src)); src = BlockPos.asLong(BlockPos.unpackLongX(src), ChunkSectionPos.getBlockCoord(ChunkSectionPos.getY(neighborCeilingSectionPos)), BlockPos.unpackLongZ(src));
final int srcLevel = neighborCeilingLightArray != null ? final int srcLevel = neighborCeilingLightArray != null ?
((ChunkLightProviderInterface) lightProvider).callGetCurrentLevelFromArray(neighborCeilingLightArray, src) ((ChunkLightProviderInterface) lightProvider).callGetCurrentLevelFromSection(neighborCeilingLightArray, src)
: this.isLightEnabled(ChunkSectionPos.withZeroZ(neighborCeilingSectionPos)) ? 0 : 15; : this.isSectionEnabled(ChunkSectionPos.withZeroZ(neighborCeilingSectionPos)) ? 0 : 15;
levelPropagator.invokeUpdateLevel(src, dst, levelPropagator.callGetPropagatedLevel(src, dst, srcLevel), true); levelPropagator.invokeUpdateLevel(src, dst, levelPropagator.callGetPropagatedLevel(src, dst, srcLevel), true);
} }
@@ -135,7 +135,7 @@ public abstract class StructureFeatureMixin<C extends FeatureConfig> implements
StructureStart structurestart1 = getStructureStartFactory().create((StructureFeature)(Object)this, chunkpos.x, chunkpos.z, BlockBox.empty(),0,worldIn.getSeed()); StructureStart structurestart1 = getStructureStartFactory().create((StructureFeature)(Object)this, chunkpos.x, chunkpos.z, BlockBox.empty(),0,worldIn.getSeed());
if (config == null) if (config == null)
config = new DefaultFeatureConfig(); config = new DefaultFeatureConfig();
structurestart1.init(worldIn.method_30349(), generator, worldIn.getStructureManager() , chunkpos.x, chunkpos.z, biome_1, config); structurestart1.init(worldIn.getRegistryManager(), generator, worldIn.getStructureManager() , chunkpos.x, chunkpos.z, biome_1, config);
structurestart = structurestart1.hasChildren() ? structurestart1 : StructureStart.DEFAULT; structurestart = structurestart1.hasChildren() ? structurestart1 : StructureStart.DEFAULT;
if (structurestart.hasChildren()) if (structurestart.hasChildren())
@@ -101,7 +101,7 @@ public abstract class WorldChunk_movableTEMixin implements WorldChunkInterface
boolean boolean_3 = chunkSection.isEmpty(); boolean boolean_3 = chunkSection.isEmpty();
if (boolean_2 != boolean_3) if (boolean_2 != boolean_3)
{ {
this.world.getChunkManager().getLightingProvider().updateSectionStatus(blockPos_1, boolean_3); this.world.getChunkManager().getLightingProvider().setSectionStatus(blockPos_1, boolean_3);
} }
if (!this.world.isClient) if (!this.world.isClient)
@@ -1088,7 +1088,7 @@ public class CarpetExpression
BlockPos pos = locator.block.getPos(); BlockPos pos = locator.block.getPos();
Biome biome = world.getBiome(pos); Biome biome = world.getBiome(pos);
// in locatebiome // in locatebiome
Identifier biomeId = cc.s.getMinecraftServer().method_30611().method_30530(Registry.BIOME_KEY).getId(biome); Identifier biomeId = cc.s.getMinecraftServer().getRegistryManager().get(Registry.BIOME_KEY).getId(biome);
Value res = new StringValue(NBTSerializableValue.nameFromRegistryId(biomeId)); Value res = new StringValue(NBTSerializableValue.nameFromRegistryId(biomeId));
return (_c, _t) -> res; return (_c, _t) -> res;
}); });
@@ -1101,7 +1101,7 @@ public class CarpetExpression
throw new InternalExpressionException("'set_biome' needs a biome name as an argument"); throw new InternalExpressionException("'set_biome' needs a biome name as an argument");
String biomeName = lv.get(locator.offset+0).evalValue(c).getString(); String biomeName = lv.get(locator.offset+0).evalValue(c).getString();
// from locatebiome command code // from locatebiome command code
Biome biome = cc.s.getMinecraftServer().method_30611().method_30530(Registry.BIOME_KEY).get(new Identifier(biomeName)); Biome biome = cc.s.getMinecraftServer().getRegistryManager().get(Registry.BIOME_KEY).get(new Identifier(biomeName));
if (biome == null) if (biome == null)
throw new InternalExpressionException("Unknown biome: "+biomeName); throw new InternalExpressionException("Unknown biome: "+biomeName);
boolean doImmediateUpdate = true; boolean doImmediateUpdate = true;