plop
This commit is contained in:
1 parent
b257e6f984
commit
e3c0edae3c
14 files changed
+501
-326
No files matched your search
@@ -0,0 +1,22 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.structure.BuriedTreasureGenerator;
|
||||
import net.minecraft.world.Heightmap;
|
||||
import net.minecraft.world.IWorld;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(BuriedTreasureGenerator.Piece.class)
|
||||
public class BuriedTreasureGeneratorPieceMixin
|
||||
{
|
||||
@Redirect(method = "generate", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/IWorld;getTop(Lnet/minecraft/world/Heightmap$Type;II)I"
|
||||
))
|
||||
private int getTop(IWorld iWorld, Heightmap.Type var1, int var2, int var3)
|
||||
{
|
||||
return iWorld.getTop(CarpetSettings.skipGenerationChecks?Heightmap.Type.OCEAN_FLOOR:Heightmap.Type.OCEAN_FLOOR_WG, var2, var3);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.world.Heightmap;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.gen.feature.FossilFeature;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(FossilFeature.class)
|
||||
public class FossilFeatureMixin
|
||||
{
|
||||
@Redirect(method = "method_13236", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/IWorld;getTop(Lnet/minecraft/world/Heightmap$Type;II)I"
|
||||
))
|
||||
private int getTop(IWorld iWorld, Heightmap.Type var1, int var2, int var3)
|
||||
{
|
||||
return iWorld.getTop(CarpetSettings.skipGenerationChecks?Heightmap.Type.OCEAN_FLOOR:Heightmap.Type.OCEAN_FLOOR_WG, var2, var3);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.structure.IglooGenerator;
|
||||
import net.minecraft.world.Heightmap;
|
||||
import net.minecraft.world.IWorld;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(IglooGenerator.Piece.class)
|
||||
public class IglooGeneratorPieceMixin
|
||||
{
|
||||
@Redirect(method = "generate", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/IWorld;getTop(Lnet/minecraft/world/Heightmap$Type;II)I"
|
||||
))
|
||||
private int getTop(IWorld iWorld, Heightmap.Type var1, int var2, int var3)
|
||||
{
|
||||
return iWorld.getTop(CarpetSettings.skipGenerationChecks?Heightmap.Type.WORLD_SURFACE:Heightmap.Type.WORLD_SURFACE_WG, var2, var3);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.structure.OceanRuinGenerator;
|
||||
import net.minecraft.world.Heightmap;
|
||||
import net.minecraft.world.IWorld;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(OceanRuinGenerator.Piece.class)
|
||||
public class OceanRuinGeneratorPieceMixin
|
||||
{
|
||||
@Redirect(method = "generate", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/IWorld;getTop(Lnet/minecraft/world/Heightmap$Type;II)I"
|
||||
))
|
||||
private int getTop(IWorld iWorld, Heightmap.Type var1, int var2, int var3)
|
||||
{
|
||||
return iWorld.getTop(CarpetSettings.skipGenerationChecks?Heightmap.Type.OCEAN_FLOOR:Heightmap.Type.OCEAN_FLOOR_WG, var2, var3);
|
||||
}
|
||||
}
|
||||
@@ -57,7 +57,7 @@ public abstract class ServerChunkManagerMixin
|
||||
Object2IntMap object2IntMap_1)
|
||||
{
|
||||
DimensionType dim = this.world.dimension.getType();
|
||||
((WorldInterface)world).getPrecookedMobs().clear();
|
||||
//((WorldInterface)world).getPrecookedMobs().clear(); not needed because mobs are compared with predefined BBs
|
||||
SpawnReporter.mobCounts.put(dim, (Object2IntMap<EntityCategory>)object2IntMap_1);
|
||||
SpawnReporter.chunkCounts.put(dim, int_2);
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.structure.ShipwreckGenerator;
|
||||
import net.minecraft.world.Heightmap;
|
||||
import net.minecraft.world.IWorld;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(ShipwreckGenerator.Piece.class)
|
||||
public class ShipwreckGeneratorPieceMixin
|
||||
{
|
||||
@Shadow @Final private boolean grounded;
|
||||
|
||||
@Redirect(method = "generate", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/IWorld;getTop(Lnet/minecraft/world/Heightmap$Type;II)I"
|
||||
))
|
||||
private int getTop(IWorld iWorld, Heightmap.Type var1, int var2, int var3)
|
||||
{
|
||||
if (grounded)
|
||||
return iWorld.getTop(CarpetSettings.skipGenerationChecks?Heightmap.Type.WORLD_SURFACE:Heightmap.Type.WORLD_SURFACE_WG, var2, var3);
|
||||
else
|
||||
return iWorld.getTop(CarpetSettings.skipGenerationChecks?Heightmap.Type.OCEAN_FLOOR:Heightmap.Type.OCEAN_FLOOR_WG, var2, var3);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetServer;
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.fakes.StructureFeatureInterface;
|
||||
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.structure.StructureStart;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.util.math.MutableIntBoundingBox;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.ChunkStatus;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.chunk.ChunkGeneratorConfig;
|
||||
import net.minecraft.world.gen.feature.StructureFeature;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@Mixin(StructureFeature.class)
|
||||
public abstract class StructureFeatureMixin implements StructureFeatureInterface
|
||||
{
|
||||
//problem is that is seems that now chunks deal with its portion of the strucuture
|
||||
//on its own.
|
||||
|
||||
@Shadow public abstract int getRadius();
|
||||
|
||||
@Shadow public abstract String getName();
|
||||
|
||||
@Shadow public abstract StructureFeature.StructureStartFactory getStructureStartFactory();
|
||||
|
||||
@Override
|
||||
public boolean plopAnywhere(IWorld world, BlockPos pos)
|
||||
{
|
||||
return plopAnywhere(world, pos, world.getChunkManager().getChunkGenerator());
|
||||
}
|
||||
public boolean plopAnywhere(IWorld world, BlockPos pos, ChunkGenerator<? extends ChunkGeneratorConfig> generator)
|
||||
{
|
||||
if (world.isClient())
|
||||
return false;
|
||||
CarpetSettings.skipGenerationChecks = true;
|
||||
try
|
||||
{
|
||||
Random rand = new Random(world.getRandom().nextInt());
|
||||
int j = pos.getX() >> 4;
|
||||
int k = pos.getZ() >> 4;
|
||||
long chId = ChunkPos.toLong(j, k);
|
||||
StructureStart structurestart = forceStructureStart(world, generator, rand, chId);
|
||||
if (structurestart == null || structurestart == StructureStart.DEFAULT)
|
||||
{
|
||||
CarpetSettings.skipGenerationChecks = false;
|
||||
return false;
|
||||
}
|
||||
//generator.ge getStructurePositionToReferenceMap(this).computeIfAbsent(chId,
|
||||
// (x) -> new LongOpenHashSet()).add(chId);
|
||||
world.getChunk(j, k, ChunkStatus.STRUCTURE_STARTS).addStructureReference(this.getName(), chId);
|
||||
MutableIntBoundingBox box = structurestart.getBoundingBox();
|
||||
structurestart.generateStructure(
|
||||
world,
|
||||
rand,
|
||||
new MutableIntBoundingBox(
|
||||
pos.getX() - this.getRadius()*16,
|
||||
pos.getZ() - this.getRadius()*16,
|
||||
pos.getX() + (this.getRadius()+1)*16,
|
||||
pos.getZ() + (1+this.getRadius())*16),
|
||||
new ChunkPos(j, k)
|
||||
);
|
||||
//structurestart.notifyPostProcessAt(new ChunkPos(j, k));
|
||||
|
||||
int i = getRadius();
|
||||
for (int k1 = j - i; k1 <= j + i; ++k1)
|
||||
{
|
||||
for (int l1 = k - i; l1 <= k + i; ++l1)
|
||||
{
|
||||
if (k1 == j && l1 == k) continue;
|
||||
long nbchkid = ChunkPos.toLong(k1, l1);
|
||||
if (box.intersectsXZ(k1<<4, l1<<4, (k1<<4) + 15, (l1<<4) + 15))
|
||||
{
|
||||
//generator.getStructurePositionToReferenceMap(this).computeIfAbsent(nbchkid, (__) -> new LongOpenHashSet()).add(chId);
|
||||
world.getChunk(k1, l1, ChunkStatus.STRUCTURE_STARTS).addStructureReference(this.getName(), chId);
|
||||
//structurestart. notifyPostProcessAt(new ChunkPos(k1, l1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ignored)
|
||||
{
|
||||
CarpetSettings.LOG.error("Unknown Exception while plopping structure: "+ignored);
|
||||
ignored.printStackTrace();
|
||||
CarpetSettings.skipGenerationChecks = false;
|
||||
return false;
|
||||
}
|
||||
CarpetSettings.skipGenerationChecks = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private StructureStart forceStructureStart(IWorld worldIn, ChunkGenerator <? extends ChunkGeneratorConfig > generator, Random rand, long packedChunkPos)
|
||||
{
|
||||
ChunkPos chunkpos = new ChunkPos(packedChunkPos);
|
||||
StructureStart structurestart = worldIn.getChunk(chunkpos.x, chunkpos.z).getStructureStart(this.getName());
|
||||
if (structurestart != null)
|
||||
{
|
||||
return structurestart; // structure already exist, will skip
|
||||
}
|
||||
|
||||
Chunk ichunk = worldIn.getChunk(chunkpos.x, chunkpos.z, ChunkStatus.STRUCTURE_STARTS);
|
||||
|
||||
if (ichunk != null)
|
||||
{
|
||||
structurestart = ichunk.getStructureStart(this.getName());
|
||||
|
||||
if (structurestart != null)
|
||||
{
|
||||
//long2objectmap.put(packedChunkPos, structurestart);
|
||||
return structurestart;
|
||||
}
|
||||
}
|
||||
Biome biome_1 = generator.getBiomeSource().getBiome(new BlockPos(chunkpos.getStartX() + 9, 0, chunkpos.getStartZ() + 9));
|
||||
StructureStart structurestart1 = getStructureStartFactory().create((StructureFeature)(Object)this, chunkpos.x, chunkpos.z, biome_1, MutableIntBoundingBox.empty(),0,generator.getSeed());
|
||||
structurestart1.initialize(generator, ((ServerWorld)worldIn).getStructureManager() , chunkpos.x, chunkpos.z, biome_1);
|
||||
structurestart = structurestart.hasChildren() ? structurestart : StructureStart.DEFAULT;
|
||||
|
||||
if (structurestart.hasChildren())
|
||||
{
|
||||
worldIn.getChunk(chunkpos.x, chunkpos.z, ChunkStatus.STRUCTURE_STARTS).setStructureStart(this.getName(), structurestart);
|
||||
}
|
||||
|
||||
//long2objectmap.put(packedChunkPos, structurestart);
|
||||
return structurestart;
|
||||
}
|
||||
}
|
||||
@@ -1,119 +0,0 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
|
||||
import net.minecraft.structure.StructureStart;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.chunk.ChunkGeneratorConfig;
|
||||
import net.minecraft.world.gen.feature.StructureFeature;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@Mixin(StructureFeature.class)
|
||||
public class StructureFeatureMixin
|
||||
{
|
||||
//problem is that is seems that now chunks deal with its portion of the strucuture
|
||||
//on its own.
|
||||
|
||||
public boolean plopAnywhere(IWorld world, BlockPos pos)
|
||||
{
|
||||
return plopAnywhere(world, pos, world.getChunkManager().getChunkGenerator());
|
||||
}
|
||||
public boolean plopAnywhere(IWorld world, BlockPos pos, ChunkGenerator<? extends ChunkGeneratorConfig> generator)
|
||||
{
|
||||
CarpetSettings.skipGenerationChecks = true;
|
||||
try
|
||||
{
|
||||
Random rand = new Random(world.getRandom().nextInt());
|
||||
int j = pos.getX() >> 4;
|
||||
int k = pos.getZ() >> 4;
|
||||
long chId = ChunkPos.toLong(j, k);
|
||||
StructureStart structurestart = forceStructureStart(world, generator, rand, chId);
|
||||
if (structurestart == null || structurestart == StructureStart.DEFAULT)
|
||||
{
|
||||
CarpetSettings.skipGenerationChecks = false;
|
||||
return false;
|
||||
}
|
||||
generator.ge getStructurePositionToReferenceMap(this).computeIfAbsent(chId, (x) -> new LongOpenHashSet()).add(chId);
|
||||
world.getChunkManager().getChunkOrPrimer(j, k, true).addStructureReference(this.getStructureName(), chId);
|
||||
MutableBoundingBox box = structurestart.getBoundingBox();
|
||||
structurestart.generateStructure(
|
||||
world,
|
||||
rand,
|
||||
new MutableBoundingBox(
|
||||
pos.getX() - this.getSize()*16,
|
||||
pos.getZ() - this.getSize()*16,
|
||||
pos.getX() + (this.getSize()+1)*16,
|
||||
pos.getZ() + (1+this.getSize())*16),
|
||||
new ChunkPos(j, k)
|
||||
);
|
||||
structurestart.notifyPostProcessAt(new ChunkPos(j, k));
|
||||
|
||||
int i = this.getSize();
|
||||
for (int k1 = j - i; k1 <= j + i; ++k1)
|
||||
{
|
||||
for (int l1 = k - i; l1 <= k + i; ++l1)
|
||||
{
|
||||
if (k1 == j && l1 == k) continue;
|
||||
long nbchkid = ChunkPos.toLong(k1, l1);
|
||||
if (box.intersectsWith(k1<<4, l1<<4, (k1<<4) + 15, (l1<<4) + 15))
|
||||
{
|
||||
generator.getStructurePositionToReferenceMap(this).computeIfAbsent(nbchkid, (__) -> new LongOpenHashSet()).add(chId);
|
||||
world.getChunkManager().getChunkOrPrimer(k1, l1, true).addStructureReference(this.getStructureName(), chId);
|
||||
structurestart.notifyPostProcessAt(new ChunkPos(k1, l1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ignored)
|
||||
{
|
||||
CarpetSettings.LOG.error("Unknown Exception while plopping structure: "+ignored);
|
||||
ignored.printStackTrace();
|
||||
CarpetSettings.skipGenerationChecks = false;
|
||||
return false;
|
||||
}
|
||||
CarpetSettings.skipGenerationChecks = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private StructureStart forceStructureStart(IWorld worldIn, ChunkGenerator <? extends ChunkGeneratorConfig > generator, Random rand, long packedChunkPos)
|
||||
{
|
||||
|
||||
Long2ObjectMap<StructureStart> long2objectmap = generator.getStructureReferenceToStartMap(this);
|
||||
StructureStart structurestart = long2objectmap.get(packedChunkPos);
|
||||
|
||||
if (structurestart != null)
|
||||
{
|
||||
return structurestart; // structure already exist, will skip
|
||||
}
|
||||
ChunkPos chunkpos = new ChunkPos(packedChunkPos);
|
||||
IChunk ichunk = worldIn.getChunkManager().getChunkOrPrimer(chunkpos.x, chunkpos.z, false);
|
||||
|
||||
if (ichunk != null)
|
||||
{
|
||||
structurestart = ichunk.getStructureStart(this.getStructureName());
|
||||
|
||||
if (structurestart != null)
|
||||
{
|
||||
long2objectmap.put(packedChunkPos, structurestart);
|
||||
return structurestart;
|
||||
}
|
||||
}
|
||||
|
||||
StructureStart structurestart1 = this.makeStart(worldIn, generator, rand, chunkpos.x, chunkpos.z);
|
||||
structurestart = structurestart1.isValid() ? structurestart1 : NO_STRUCTURE;
|
||||
|
||||
if (structurestart.isValid())
|
||||
{
|
||||
worldIn.getChunkManager().getChunkOrPrimer(chunkpos.x, chunkpos.z, true).putStructureStart(this.getStructureName(), structurestart);
|
||||
}
|
||||
|
||||
long2objectmap.put(packedChunkPos, structurestart);
|
||||
return structurestart;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.structure.StructurePiece;
|
||||
import net.minecraft.world.Heightmap;
|
||||
import net.minecraft.world.ViewableWorld;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(StructurePiece.class)
|
||||
public class StructurePieceMixin
|
||||
{
|
||||
@Redirect(method = "isUnderSeaLevel", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/ViewableWorld;getTop(Lnet/minecraft/world/Heightmap$Type;II)I"
|
||||
))
|
||||
private int getTop(ViewableWorld viewableWorld, Heightmap.Type var1, int var2, int var3)
|
||||
{
|
||||
return viewableWorld.getTop(CarpetSettings.skipGenerationChecks?Heightmap.Type.OCEAN_FLOOR:Heightmap.Type.OCEAN_FLOOR_WG, var2, var3);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user