20w22a
This commit is contained in:
1 parent
61524b1486
commit
3b588e8488
20 files changed
+103
-98
No files matched your search
@@ -15,6 +15,7 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Box;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -523,7 +524,7 @@ public class CarpetSettings
|
||||
public static class ChangeSpawnChunksValidator extends Validator<Integer> {
|
||||
public static void changeSpawnSize(int size)
|
||||
{
|
||||
ServerWorld overworld = CarpetServer.minecraft_server.getWorld(DimensionType.OVERWORLD_REGISTRY_KEY); // OW
|
||||
ServerWorld overworld = CarpetServer.minecraft_server.getWorld(World.field_25179); // OW
|
||||
if (overworld != null) {
|
||||
ChunkPos centerChunk = new ChunkPos(new BlockPos(
|
||||
overworld.getLevelProperties().getSpawnX(),
|
||||
@@ -544,7 +545,7 @@ public class CarpetSettings
|
||||
//must been some startup thing
|
||||
return newValue;
|
||||
}
|
||||
ServerWorld currentOverworld = CarpetServer.minecraft_server.getWorld(DimensionType.OVERWORLD_REGISTRY_KEY); // OW
|
||||
ServerWorld currentOverworld = CarpetServer.minecraft_server.getWorld(World.field_25179); // OW
|
||||
if (currentOverworld != null)
|
||||
{
|
||||
changeSpawnSize(newValue);
|
||||
|
||||
@@ -28,6 +28,7 @@ import net.minecraft.util.math.Vec2f;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.registry.RegistryKey;
|
||||
import net.minecraft.world.GameMode;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -235,7 +236,7 @@ public class PlayerCommand
|
||||
() -> RotationArgumentType.getRotation(context, "direction").toAbsoluteRotation(context.getSource()),
|
||||
source::getRotation
|
||||
);
|
||||
RegistryKey<DimensionType> dimType = tryGetArg(
|
||||
RegistryKey<World> dimType = tryGetArg(
|
||||
() -> DimensionArgumentType.getDimensionArgument(context, "dimension"),
|
||||
() -> source.getWorld().method_27983() // dimension.getType()
|
||||
);
|
||||
|
||||
@@ -19,6 +19,7 @@ import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.util.DyeColor;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.registry.RegistryKey;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -258,7 +259,7 @@ public class SpawnCommand
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static int mobcapsForDimension(ServerCommandSource source, RegistryKey<DimensionType> dim)
|
||||
private static int mobcapsForDimension(ServerCommandSource source, RegistryKey<World> dim)
|
||||
{
|
||||
Messenger.send(source, SpawnReporter.printMobcapsForDimension(source.getMinecraftServer().getWorld(dim), true));
|
||||
return 1;
|
||||
|
||||
@@ -61,11 +61,6 @@ import static net.minecraft.world.biome.DefaultBiomeFeatures.OAK_TREE_CONFIG;
|
||||
|
||||
public class FeatureGenerator
|
||||
{
|
||||
public static String fix(String key)
|
||||
{
|
||||
return key.toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
private interface Thing
|
||||
{
|
||||
@@ -156,28 +151,28 @@ public class FeatureGenerator
|
||||
}
|
||||
|
||||
|
||||
public static final Map<String, List<String>> structureToFeature = new HashMap<>();
|
||||
public static final Map<String, String> featureToStructure = new HashMap<>();
|
||||
public static final Map<StructureFeature<?>, List<String>> structureToFeature = new HashMap<>();
|
||||
public static final Map<String, StructureFeature<?>> featureToStructure = new HashMap<>();
|
||||
static
|
||||
{
|
||||
structureToFeature.put(StructureFeature.MONUMENT.getName(), Collections.singletonList("monument"));
|
||||
structureToFeature.put(StructureFeature.END_CITY.getName(), Collections.singletonList("end_city"));
|
||||
structureToFeature.put(StructureFeature.OCEAN_RUIN.getName(), Arrays.asList("ocean_ruin", "ocean_ruin_warm", "ocean_ruin_small", "ocean_ruin_warm_small", "ocean_ruin_tall", "ocean_ruin_warm_tall"));
|
||||
structureToFeature.put(StructureFeature.VILLAGE.getName(), Arrays.asList("village", "village_desert", "village_savanna", "village_taiga", "village_snowy"));
|
||||
structureToFeature.put(StructureFeature.MANSION.getName(), Collections.singletonList("mansion"));
|
||||
structureToFeature.put(StructureFeature.BURIED_TREASURE.getName(), Collections.singletonList("treasure"));
|
||||
structureToFeature.put(StructureFeature.field_24851.getName(), Collections.singletonList("witch_hut"));
|
||||
structureToFeature.put(StructureFeature.STRONGHOLD.getName(), Collections.singletonList("stronghold"));
|
||||
structureToFeature.put(StructureFeature.DESERT_PYRAMID.getName(), Collections.singletonList("desert_temple"));
|
||||
structureToFeature.put(StructureFeature.JUNGLE_PYRAMID.getName(), Collections.singletonList("jungle_temple"));
|
||||
structureToFeature.put(StructureFeature.SHIPWRECK.getName(), Arrays.asList("shipwreck", "shipwreck2"));
|
||||
structureToFeature.put(StructureFeature.PILLAGER_OUTPOST.getName(), Collections.singletonList("pillager_outpost"));
|
||||
structureToFeature.put(StructureFeature.MINESHAFT.getName(), Arrays.asList("mineshaft", "mineshaft_mesa"));
|
||||
structureToFeature.put(StructureFeature.IGLOO.getName(), Collections.singletonList("igloo"));
|
||||
structureToFeature.put(StructureFeature.FORTRESS.getName(), Collections.singletonList("fortress"));
|
||||
structureToFeature.put(StructureFeature.NETHER_FOSSIL.getName(), Collections.singletonList("nether_fossil"));
|
||||
structureToFeature.put(StructureFeature.BASTION_REMNANT.getName(), Arrays.asList("bastion_remnant", "bastion_remnant_housing", "bastion_remnant_stable", "bastion_remnant_treasure", "bastion_remnant_bridge"));
|
||||
structureToFeature.put(StructureFeature.RUINED_PORTAL.getName(), Collections.singletonList("ruined_portal"));
|
||||
structureToFeature.put(StructureFeature.MONUMENT, Collections.singletonList("monument"));
|
||||
structureToFeature.put(StructureFeature.END_CITY, Collections.singletonList("end_city"));
|
||||
structureToFeature.put(StructureFeature.OCEAN_RUIN, Arrays.asList("ocean_ruin", "ocean_ruin_warm", "ocean_ruin_small", "ocean_ruin_warm_small", "ocean_ruin_tall", "ocean_ruin_warm_tall"));
|
||||
structureToFeature.put(StructureFeature.VILLAGE, Arrays.asList("village", "village_desert", "village_savanna", "village_taiga", "village_snowy"));
|
||||
structureToFeature.put(StructureFeature.MANSION, Collections.singletonList("mansion"));
|
||||
structureToFeature.put(StructureFeature.BURIED_TREASURE, Collections.singletonList("treasure"));
|
||||
structureToFeature.put(StructureFeature.field_24851, Collections.singletonList("witch_hut"));
|
||||
structureToFeature.put(StructureFeature.STRONGHOLD, Collections.singletonList("stronghold"));
|
||||
structureToFeature.put(StructureFeature.DESERT_PYRAMID, Collections.singletonList("desert_temple"));
|
||||
structureToFeature.put(StructureFeature.JUNGLE_PYRAMID, Collections.singletonList("jungle_temple"));
|
||||
structureToFeature.put(StructureFeature.SHIPWRECK, Arrays.asList("shipwreck", "shipwreck2"));
|
||||
structureToFeature.put(StructureFeature.PILLAGER_OUTPOST, Collections.singletonList("pillager_outpost"));
|
||||
structureToFeature.put(StructureFeature.MINESHAFT, Arrays.asList("mineshaft", "mineshaft_mesa"));
|
||||
structureToFeature.put(StructureFeature.IGLOO, Collections.singletonList("igloo"));
|
||||
structureToFeature.put(StructureFeature.FORTRESS, Collections.singletonList("fortress"));
|
||||
structureToFeature.put(StructureFeature.NETHER_FOSSIL, Collections.singletonList("nether_fossil"));
|
||||
structureToFeature.put(StructureFeature.BASTION_REMNANT, Arrays.asList("bastion_remnant", "bastion_remnant_housing", "bastion_remnant_stable", "bastion_remnant_treasure", "bastion_remnant_bridge"));
|
||||
structureToFeature.put(StructureFeature.RUINED_PORTAL, Collections.singletonList("ruined_portal"));
|
||||
|
||||
structureToFeature.forEach((key, value) -> value.forEach(el -> featureToStructure.put(el, key)));
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.text.BaseText;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -50,7 +51,7 @@ public class HopperCounter
|
||||
{
|
||||
if (startTick == 0)
|
||||
{
|
||||
startTick = server.getWorld(DimensionType.OVERWORLD_REGISTRY_KEY).getTime(); //OW
|
||||
startTick = server.getWorld(World.field_25179).getTime(); //OW
|
||||
startMillis = System.currentTimeMillis();
|
||||
}
|
||||
Item item = stack.getItem();
|
||||
@@ -61,7 +62,7 @@ public class HopperCounter
|
||||
public void reset(MinecraftServer server)
|
||||
{
|
||||
counter.clear();
|
||||
startTick = server.getWorld(DimensionType.OVERWORLD_REGISTRY_KEY).getTime(); //OW
|
||||
startTick = server.getWorld(World.field_25179).getTime(); //OW
|
||||
startMillis = System.currentTimeMillis();
|
||||
// pubSubProvider.publish();
|
||||
}
|
||||
@@ -105,7 +106,7 @@ public class HopperCounter
|
||||
return Collections.singletonList(Messenger.s(String.format("No items for %s yet", color.getName())));
|
||||
}
|
||||
long total = getTotalItems();
|
||||
long ticks = Math.max(realTime ? (System.currentTimeMillis() - startMillis) / 50 : server.getWorld(DimensionType.OVERWORLD_REGISTRY_KEY).getTime() - startTick, 1); //OW
|
||||
long ticks = Math.max(realTime ? (System.currentTimeMillis() - startMillis) / 50 : server.getWorld(World.field_25179).getTime() - startTick, 1); //OW
|
||||
if (total == 0)
|
||||
{
|
||||
if (brief)
|
||||
|
||||
@@ -66,8 +66,8 @@ public abstract class PistonBlock_movableTEMixin extends FacingBlock
|
||||
target = "Ljava/util/List;size()I", ordinal = 4),locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
private void onMove(World world_1, BlockPos blockPos_1, Direction direction_1, boolean boolean_1,
|
||||
CallbackInfoReturnable<Boolean> cir, BlockPos blockPos_2, PistonHandler pistonHandler_1, Map map_1,
|
||||
List<BlockPos> list_1, List<BlockState> list_2, List list_3, int int_2, BlockState[] blockStates_1,
|
||||
Direction direction_2)
|
||||
List<BlockPos> list_1, List<BlockState> list_2, List list_3, BlockState[] blockStates_1,
|
||||
Direction direction_2, int int_2)
|
||||
{
|
||||
//Get the blockEntities and remove them from the world before any magic starts to happen
|
||||
if (CarpetSettings.movableBlockEntities)
|
||||
@@ -95,7 +95,7 @@ public abstract class PistonBlock_movableTEMixin extends FacingBlock
|
||||
locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
private void setBlockEntityWithCarried(World world_1, BlockPos blockPos_1, Direction direction_1, boolean boolean_1,
|
||||
CallbackInfoReturnable<Boolean> cir, BlockPos blockPos_2, PistonHandler pistonHandler_1, Map map_1, List list_1,
|
||||
List list_2, List list_3, int int_2, BlockState[] blockStates_1, Direction direction_2,
|
||||
List list_2, List list_3, BlockState[] blockStates_1, Direction direction_2, int int_2,
|
||||
int int_3, BlockPos blockPos_4, BlockState blockState_1)
|
||||
{
|
||||
BlockEntity blockEntityPiston = PistonExtensionBlock.createBlockEntityPiston((BlockState) list_2.get(int_3),
|
||||
|
||||
@@ -10,6 +10,7 @@ import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.registry.RegistryKey;
|
||||
import net.minecraft.world.SpawnHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldProperties;
|
||||
import net.minecraft.world.chunk.WorldChunk;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
@@ -48,7 +49,7 @@ public abstract class ServerChunkManagerMixin implements ServerChunkManagerInter
|
||||
private int setupTracking(ChunkTicketManager chunkTicketManager)
|
||||
{
|
||||
int j = chunkTicketManager.getSpawningChunkCount();
|
||||
RegistryKey<DimensionType> dim = this.world.method_27983(); // getDimensionType;
|
||||
RegistryKey<World> dim = this.world.method_27983(); // getDimensionType;
|
||||
//((WorldInterface)world).getPrecookedMobs().clear(); not needed because mobs are compared with predefined BBs
|
||||
SpawnReporter.chunkCounts.put(dim, j);
|
||||
|
||||
@@ -78,7 +79,7 @@ public abstract class ServerChunkManagerMixin implements ServerChunkManagerInter
|
||||
{
|
||||
for (SpawnGroup cat: SpawnGroup.values())
|
||||
{
|
||||
RegistryKey<DimensionType> dim = world.method_27983(); // getDimensionType;
|
||||
RegistryKey<World> dim = world.method_27983(); // getDimensionType;
|
||||
Pair key = Pair.of(dim, cat);
|
||||
int spawnTries = SpawnReporter.spawn_tries.get(cat);
|
||||
if (!SpawnReporter.local_spawns.containsKey(cat))
|
||||
|
||||
@@ -89,7 +89,7 @@ public abstract class ServerPlayerEntity_scarpetEventMixin extends PlayerEntity
|
||||
}
|
||||
|
||||
private Vec3d previousLocation;
|
||||
private RegistryKey<DimensionType> previousDimension;
|
||||
private RegistryKey<World> previousDimension;
|
||||
|
||||
@Inject(method = "changeDimension", at = @At("HEAD"))
|
||||
private void logPreviousCoordinates(RegistryKey<DimensionType> newDimension, CallbackInfoReturnable<Entity> cir)
|
||||
@@ -99,13 +99,13 @@ public abstract class ServerPlayerEntity_scarpetEventMixin extends PlayerEntity
|
||||
}
|
||||
|
||||
@Inject(method = "changeDimension", at = @At("RETURN"))
|
||||
private void atChangeDimension(RegistryKey<DimensionType> newDimension, CallbackInfoReturnable<Entity> cir)
|
||||
private void atChangeDimension(RegistryKey<World> newDimension, CallbackInfoReturnable<Entity> cir)
|
||||
{
|
||||
if (PLAYER_CHANGES_DIMENSION.isNeeded())
|
||||
{
|
||||
ServerPlayerEntity player = (ServerPlayerEntity) (Object)this;
|
||||
Vec3d to = null;
|
||||
if (!notInAnyWorld || previousDimension != DimensionType.THE_END_REGISTRY_KEY || newDimension != DimensionType.OVERWORLD_REGISTRY_KEY) // end ow
|
||||
if (!notInAnyWorld || previousDimension != World.field_25181 || newDimension != World.field_25179) // end ow
|
||||
{
|
||||
to = getPos();
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import carpet.utils.CarpetProfiler;
|
||||
import net.minecraft.entity.raid.RaidManager;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.profiler.Profiler;
|
||||
import net.minecraft.util.registry.RegistryKey;
|
||||
import net.minecraft.world.MutableWorldProperties;
|
||||
import net.minecraft.world.WanderingTraderManager;
|
||||
import net.minecraft.world.World;
|
||||
@@ -28,9 +29,9 @@ public abstract class ServerWorld_tickMixin extends World
|
||||
//@Shadow protected abstract void sendBlockActions();
|
||||
|
||||
@Shadow protected abstract void method_29203();
|
||||
protected ServerWorld_tickMixin(MutableWorldProperties mutableWorldProperties, DimensionType dimensionType, Supplier<Profiler> supplier, boolean bl, boolean bl2, long l)
|
||||
protected ServerWorld_tickMixin(MutableWorldProperties mutableWorldProperties, RegistryKey<World> registryKey, RegistryKey<DimensionType> registryKey2, DimensionType dimensionType, Supplier<Profiler> supplier, boolean bl, boolean bl2, long l)
|
||||
{
|
||||
super(mutableWorldProperties, dimensionType, supplier, bl, bl2, l);
|
||||
super(mutableWorldProperties, registryKey, registryKey2, dimensionType, supplier, bl, bl2, l);
|
||||
}
|
||||
|
||||
private CarpetProfiler.ProfilerToken currentSection;
|
||||
|
||||
@@ -281,7 +281,7 @@ public class SpawnHelperMixin
|
||||
SpawnGroup entityCategory = var6[var8];
|
||||
if ((spawnAnimals || !entityCategory.isPeaceful()) && (spawnMonsters || entityCategory.isPeaceful()) && (shouldSpawnAnimals || !entityCategory.isAnimal()) )
|
||||
{
|
||||
RegistryKey<DimensionType> dim = world.method_27983(); // getDimensionType;
|
||||
RegistryKey<World> dim = world.method_27983(); // getDimensionType;
|
||||
int newCap = (int) ((double)entityCategory.getCapacity()*(Math.pow(2.0,(SpawnReporter.mobcap_exponent/4))));
|
||||
int int_2 = SpawnReporter.chunkCounts.get(dim); // eligible chunks for spawning
|
||||
int int_3 = newCap * int_2 / CHUNK_AREA; //current spawning limits
|
||||
|
||||
@@ -10,20 +10,22 @@ import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@Mixin(StructureBlockBlockEntity.class)
|
||||
public abstract class StructureBlockBlockEntity_fillUpdatesMixin
|
||||
{
|
||||
@Redirect(method = "place", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/structure/Structure;place(Lnet/minecraft/world/WorldAccess;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/structure/StructurePlacementData;)V"
|
||||
target = "Lnet/minecraft/structure/Structure;place(Lnet/minecraft/world/WorldAccess;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/structure/StructurePlacementData;Ljava/util/Random;)V"
|
||||
))
|
||||
private void onStructurePlacen(Structure structure, WorldAccess WorldAccess_1, BlockPos blockPos_1, StructurePlacementData structurePlacementData_1)
|
||||
private void onStructurePlacen(Structure structure, WorldAccess world, BlockPos pos, StructurePlacementData placementData, Random random)
|
||||
{
|
||||
if(!CarpetSettings.fillUpdates)
|
||||
CarpetSettings.impendingFillSkipUpdates = true;
|
||||
try
|
||||
{
|
||||
structure.place(WorldAccess_1, blockPos_1, structurePlacementData_1);
|
||||
structure.place(world, pos, placementData, random);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
@@ -66,7 +66,7 @@ public abstract class StructureFeatureMixin<C extends FeatureConfig> implements
|
||||
}
|
||||
//generator.ge getStructurePositionToReferenceMap(this).computeIfAbsent(chId,
|
||||
// (x) -> new LongOpenHashSet()).add(chId);
|
||||
world.getChunk(j, k).addStructureReference(this.getName(), chId); //, ChunkStatus.STRUCTURE_STARTS
|
||||
world.getChunk(j, k).addStructureReference((StructureFeature) (Object)this, chId); //, ChunkStatus.STRUCTURE_STARTS
|
||||
|
||||
BlockBox box = structurestart.getBoundingBox();
|
||||
if (!wireOnly)
|
||||
@@ -93,7 +93,7 @@ public abstract class StructureFeatureMixin<C extends FeatureConfig> implements
|
||||
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).addStructureReference(this.getName(), chId); //, ChunkStatus.STRUCTURE_STARTS
|
||||
world.getChunk(k1, l1).addStructureReference((StructureFeature) (Object)this, chId); //, ChunkStatus.STRUCTURE_STARTS
|
||||
//structurestart. notifyPostProcessAt(new ChunkPos(k1, l1));
|
||||
}
|
||||
}
|
||||
@@ -121,7 +121,7 @@ public abstract class StructureFeatureMixin<C extends FeatureConfig> implements
|
||||
|
||||
if (ichunk != null)
|
||||
{
|
||||
structurestart = ichunk.getStructureStart(this.getName());
|
||||
structurestart = ichunk.getStructureStart((StructureFeature)(Object)this);
|
||||
|
||||
if (structurestart != null && structurestart != StructureStart.DEFAULT)
|
||||
{
|
||||
@@ -140,7 +140,7 @@ public abstract class StructureFeatureMixin<C extends FeatureConfig> implements
|
||||
|
||||
if (structurestart.hasChildren())
|
||||
{
|
||||
worldIn.getChunk(chunkpos.x, chunkpos.z).setStructureStart(this.getName(), structurestart);
|
||||
worldIn.getChunk(chunkpos.x, chunkpos.z).setStructureStart((StructureFeature)(Object)this, structurestart);
|
||||
}
|
||||
|
||||
//long2objectmap.put(packedChunkPos, structurestart);
|
||||
|
||||
@@ -13,7 +13,7 @@ import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
@Mixin(Structure.class)
|
||||
public class Structure_fillUpdatesMixin
|
||||
{
|
||||
@Redirect( method = "place(Lnet/minecraft/world/WorldAccess;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/structure/StructurePlacementData;I)Z", at = @At(
|
||||
@Redirect( method = "place(Lnet/minecraft/world/WorldAccess;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/structure/StructurePlacementData;Ljava/util/Random;I)Z", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/WorldAccess;updateNeighbors(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/Block;)V"
|
||||
))
|
||||
@@ -23,7 +23,7 @@ public class Structure_fillUpdatesMixin
|
||||
WorldAccess.updateNeighbors(var1, var2);
|
||||
}
|
||||
|
||||
@Redirect(method = "place(Lnet/minecraft/world/WorldAccess;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/structure/StructurePlacementData;I)Z", at = @At(
|
||||
@Redirect(method = "place(Lnet/minecraft/world/WorldAccess;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/structure/StructurePlacementData;Ljava/util/Random;I)Z", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/structure/StructurePlacementData;shouldUpdateNeighbors()Z"
|
||||
))
|
||||
|
||||
@@ -16,6 +16,7 @@ import net.minecraft.server.network.ServerPlayerInteractionManager;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.registry.RegistryKey;
|
||||
import net.minecraft.world.GameMode;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import carpet.fakes.ServerPlayerEntityInterface;
|
||||
import carpet.utils.Messenger;
|
||||
@@ -26,7 +27,7 @@ public class EntityPlayerMPFake extends ServerPlayerEntity
|
||||
public Runnable fixStartingPosition = () -> {};
|
||||
public boolean isAShadow;
|
||||
|
||||
public static EntityPlayerMPFake createFake(String username, MinecraftServer server, double d0, double d1, double d2, double yaw, double pitch, RegistryKey<DimensionType> dimensionId, GameMode gamemode)
|
||||
public static EntityPlayerMPFake createFake(String username, MinecraftServer server, double d0, double d1, double d2, double yaw, double pitch, RegistryKey<World> dimensionId, GameMode gamemode)
|
||||
{
|
||||
//prolly half of that crap is not necessary, but it works
|
||||
ServerWorld worldIn = server.getWorld(dimensionId);
|
||||
|
||||
@@ -29,6 +29,7 @@ import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.registry.RegistryKey;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
@@ -191,7 +192,7 @@ public class CarpetEventServer
|
||||
{
|
||||
handler.call(Collections::emptyList, () ->
|
||||
CarpetServer.minecraft_server.getCommandSource().
|
||||
withWorld(CarpetServer.minecraft_server.getWorld(DimensionType.OVERWORLD_REGISTRY_KEY))
|
||||
withWorld(CarpetServer.minecraft_server.getWorld(World.field_25179))
|
||||
);
|
||||
}
|
||||
},
|
||||
@@ -202,7 +203,7 @@ public class CarpetEventServer
|
||||
{
|
||||
handler.call(Collections::emptyList, () ->
|
||||
CarpetServer.minecraft_server.getCommandSource().
|
||||
withWorld(CarpetServer.minecraft_server.getWorld(DimensionType.THE_NETHER_REGISTRY_KEY))
|
||||
withWorld(CarpetServer.minecraft_server.getWorld(World.field_25180))
|
||||
);
|
||||
}
|
||||
},
|
||||
@@ -213,7 +214,7 @@ public class CarpetEventServer
|
||||
{
|
||||
handler.call(Collections::emptyList, () ->
|
||||
CarpetServer.minecraft_server.getCommandSource().
|
||||
withWorld(CarpetServer.minecraft_server.getWorld(DimensionType.THE_END_REGISTRY_KEY))
|
||||
withWorld(CarpetServer.minecraft_server.getWorld(World.field_25181))
|
||||
);
|
||||
}
|
||||
},
|
||||
@@ -531,7 +532,7 @@ public class CarpetEventServer
|
||||
PLAYER_CHANGES_DIMENSION("player_changes_dimension", 5, false)
|
||||
{
|
||||
@Override
|
||||
public void onDimensionChange(ServerPlayerEntity player, Vec3d from, Vec3d to, RegistryKey<DimensionType> fromDim, RegistryKey<DimensionType> dimTo)
|
||||
public void onDimensionChange(ServerPlayerEntity player, Vec3d from, Vec3d to, RegistryKey<World> fromDim, RegistryKey<World> dimTo)
|
||||
{
|
||||
// eligibility already checked in mixin
|
||||
Value fromValue = ListValue.fromTriple(from.x, from.y, from.z);
|
||||
@@ -620,7 +621,7 @@ public class CarpetEventServer
|
||||
public void onBlockBroken(ServerPlayerEntity player, BlockPos pos, BlockState previousBS) { }
|
||||
public void onBlockPlaced(ServerPlayerEntity player, BlockPos pos, Hand enumhand, ItemStack itemstack) { }
|
||||
public void onEntityAction(ServerPlayerEntity player, Entity entity, Hand enumhand) { }
|
||||
public void onDimensionChange(ServerPlayerEntity player, Vec3d from, Vec3d to, RegistryKey<DimensionType> fromDim, RegistryKey<DimensionType> dimTo) {}
|
||||
public void onDimensionChange(ServerPlayerEntity player, Vec3d from, Vec3d to, RegistryKey<World> fromDim, RegistryKey<World> dimTo) {}
|
||||
public void onDamage(Entity target, float amount, DamageSource source) { }
|
||||
|
||||
|
||||
|
||||
@@ -945,7 +945,7 @@ public class CarpetExpression
|
||||
boolean dropLoot = true;
|
||||
if (playerBreak)
|
||||
{
|
||||
boolean isUsingEffectiveTool = state.getMaterial().canBreakByHand() || tool.isEffectiveOn(state);
|
||||
boolean isUsingEffectiveTool = !state.method_29291() || tool.isEffectiveOn(state); //!can break by hand
|
||||
//postMine() durability from item classes
|
||||
float hardness = state.getHardness(world, where);
|
||||
int damageAmount = 0;
|
||||
@@ -1155,19 +1155,19 @@ public class CarpetExpression
|
||||
BlockArgument locator = BlockArgument.findIn(cc, lv, 0);
|
||||
ServerWorld world = cc.s.getWorld();
|
||||
BlockPos pos = locator.block.getPos();
|
||||
Map<String, LongSet> references = world.getChunk(pos.getX() >> 4, pos.getZ() >> 4, ChunkStatus.STRUCTURE_REFERENCES).getStructureReferences();
|
||||
Map<StructureFeature<?>, LongSet> references = world.getChunk(pos.getX() >> 4, pos.getZ() >> 4, ChunkStatus.STRUCTURE_REFERENCES).getStructureReferences();
|
||||
if (lv.size() == locator.offset)
|
||||
{
|
||||
//CarpetSettings.LOG.error(references.keySet().stream().collect(Collectors.joining(",")));
|
||||
List<Value> referenceList = references.entrySet().stream().
|
||||
filter(e -> e.getValue()!= null && !e.getValue().isEmpty()).
|
||||
map(e -> new StringValue(FeatureGenerator.structureToFeature.get(FeatureGenerator.fix(e.getKey())).get(0))).collect(Collectors.toList());
|
||||
map(e -> new StringValue(FeatureGenerator.structureToFeature.get(e.getKey()).get(0))).collect(Collectors.toList());
|
||||
return (_c, _t ) -> ListValue.wrap(referenceList);
|
||||
}
|
||||
String simpleStructureName = lv.get(locator.offset).evalValue(c).getString().toLowerCase(Locale.ROOT);
|
||||
//CarpetSettings.LOG.error(FeatureGenerator.featureToStructure.keySet().stream().collect(Collectors.joining(",")));
|
||||
//CarpetSettings.LOG.error(FeatureGenerator.featureToStructure.values().stream().collect(Collectors.joining(",")));
|
||||
String structureName = FeatureGenerator.featureToStructure.get(simpleStructureName);
|
||||
StructureFeature<?> structureName = FeatureGenerator.featureToStructure.get(simpleStructureName);
|
||||
if (structureName == null) return LazyValue.NULL;
|
||||
LongSet structureReferences = references.get(structureName);
|
||||
if (structureReferences == null || structureReferences.isEmpty()) return ListValue.lazyEmpty();
|
||||
@@ -1179,7 +1179,7 @@ public class CarpetExpression
|
||||
});
|
||||
|
||||
this.expr.addLazyFunction("structure_eligibility", -1, (c, t, lv) ->
|
||||
{
|
||||
{// TODO rename structureName to class
|
||||
CarpetContext cc = (CarpetContext)c;
|
||||
BlockArgument locator = BlockArgument.findIn(cc, lv, 0);
|
||||
|
||||
@@ -1193,10 +1193,8 @@ public class CarpetExpression
|
||||
if (!(requested instanceof NullValue))
|
||||
{
|
||||
String reqString = requested.getString();
|
||||
String structureName = FeatureGenerator.featureToStructure.get(reqString);
|
||||
if (structureName == null) throw new InternalExpressionException("Unknown structure: " + reqString);
|
||||
structure = StructureFeature.STRUCTURES.get(structureName.toLowerCase(Locale.ROOT));
|
||||
if (structure == null) throw new InternalExpressionException("Unsupported structure: " + structureName);
|
||||
structure = FeatureGenerator.featureToStructure.get(reqString);
|
||||
if (structure == null) throw new InternalExpressionException("Unknown structure: " + reqString);
|
||||
}
|
||||
if (lv.size() > locator.offset+1)
|
||||
{
|
||||
@@ -1217,7 +1215,7 @@ public class CarpetExpression
|
||||
StructureStart start = FeatureGenerator.shouldStructureStartAt(world, pos, str, needSize);
|
||||
if (start == null) continue;
|
||||
|
||||
Value key = new StringValue(FeatureGenerator.structureToFeature.get(FeatureGenerator.fix(str.getName())).get(0));
|
||||
Value key = new StringValue(FeatureGenerator.structureToFeature.get(str).get(0));
|
||||
ret.put(key, (!needSize)?Value.NULL:structureToValue(start));
|
||||
}
|
||||
Value retMap = MapValue.wrap(ret);
|
||||
@@ -1230,18 +1228,18 @@ public class CarpetExpression
|
||||
|
||||
ServerWorld world = cc.s.getWorld();
|
||||
BlockPos pos = locator.block.getPos();
|
||||
Map<String, StructureStart<?>> structures = world.getChunk(pos.getX() >> 4, pos.getZ() >> 4, ChunkStatus.STRUCTURE_STARTS).getStructureStarts();
|
||||
Map<StructureFeature<?>, StructureStart<?>> structures = world.getChunk(pos.getX() >> 4, pos.getZ() >> 4, ChunkStatus.STRUCTURE_STARTS).getStructureStarts();
|
||||
if (lv.size() == locator.offset)
|
||||
{
|
||||
Map<Value, Value> structureList = new HashMap<>();
|
||||
for (Map.Entry<String, StructureStart<?>> entry : structures.entrySet())
|
||||
for (Map.Entry<StructureFeature<?>, StructureStart<?>> entry : structures.entrySet())
|
||||
{
|
||||
StructureStart<?> start = entry.getValue();
|
||||
if (start == StructureStart.DEFAULT)
|
||||
continue;
|
||||
BlockBox box = start.getBoundingBox();
|
||||
structureList.put(
|
||||
new StringValue(FeatureGenerator.structureToFeature.get(FeatureGenerator.fix(entry.getKey())).get(0)),
|
||||
new StringValue(FeatureGenerator.structureToFeature.get(entry.getKey()).get(0)),
|
||||
ListValue.of(ListValue.fromTriple(box.minX, box.minY, box.minZ), ListValue.fromTriple(box.maxX, box.maxY, box.maxZ))
|
||||
);
|
||||
}
|
||||
@@ -1265,14 +1263,14 @@ public class CarpetExpression
|
||||
if (lv.size() == locator.offset)
|
||||
throw new InternalExpressionException("'set_structure requires at least position and a structure name");
|
||||
String structureName = lv.get(locator.offset).evalValue(c).getString().toLowerCase(Locale.ROOT);
|
||||
String structureId = FeatureGenerator.featureToStructure.get(structureName);
|
||||
StructureFeature<?> structureId = FeatureGenerator.featureToStructure.get(structureName);
|
||||
if (structureId == null) throw new InternalExpressionException("Unknown structure: "+structureName);
|
||||
// good 'ol pointer
|
||||
Value[] result = new Value[]{Value.NULL};
|
||||
// technically a world modification. Even if we could let it slide, we will still park it
|
||||
((CarpetContext) c).s.getMinecraftServer().submitAndJoin(() ->
|
||||
{
|
||||
Map<String, StructureStart<?>> structures = world.getChunk(pos).getStructureStarts();
|
||||
Map<StructureFeature<?>, StructureStart<?>> structures = world.getChunk(pos).getStructureStarts();
|
||||
if (lv.size() == locator.offset + 1)
|
||||
{
|
||||
Boolean res = FeatureGenerator.gridStructure(structureName, ((CarpetContext) c).s.getWorld(), locator.block.getPos());
|
||||
@@ -1296,7 +1294,7 @@ public class CarpetExpression
|
||||
{
|
||||
ChunkPos chpos = new ChunkPos(chx, chz);
|
||||
// getting a chunk will convert it to full, allowing to modify references
|
||||
Map<String, LongSet> references = world.getChunk(chpos.getCenterBlockPos()).getStructureReferences();
|
||||
Map<StructureFeature<?>, LongSet> references = world.getChunk(chpos.getCenterBlockPos()).getStructureReferences();
|
||||
if (references.containsKey(structureId) && references.get(structureId) != null)
|
||||
references.get(structureId).remove(structureChunkPos.toLong());
|
||||
}
|
||||
@@ -3029,15 +3027,15 @@ public class CarpetExpression
|
||||
{
|
||||
case "nether":
|
||||
case "the_nether":
|
||||
innerSource = outerSource.withWorld(outerSource.getMinecraftServer().getWorld(DimensionType.THE_NETHER_REGISTRY_KEY));
|
||||
innerSource = outerSource.withWorld(outerSource.getMinecraftServer().getWorld(World.field_25180)); //nether
|
||||
break;
|
||||
case "end":
|
||||
case "the_end":
|
||||
innerSource = outerSource.withWorld(outerSource.getMinecraftServer().getWorld(DimensionType.THE_END_REGISTRY_KEY));
|
||||
innerSource = outerSource.withWorld(outerSource.getMinecraftServer().getWorld(World.field_25181)); //end
|
||||
break;
|
||||
case "overworld":
|
||||
case "over_world":
|
||||
innerSource = outerSource.withWorld(outerSource.getMinecraftServer().getWorld(DimensionType.OVERWORLD_REGISTRY_KEY));
|
||||
innerSource = outerSource.withWorld(outerSource.getMinecraftServer().getWorld(World.field_25179)); //ow
|
||||
break;
|
||||
default:
|
||||
throw new InternalExpressionException("Incorrect dimension string: "+dimString);
|
||||
|
||||
@@ -13,6 +13,7 @@ import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.text.BaseText;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.util.registry.RegistryKey;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -59,17 +60,17 @@ public class HUDController
|
||||
|
||||
if (LoggerRegistry.__mobcaps)
|
||||
LoggerRegistry.getLogger("mobcaps").log((option, player) -> {
|
||||
RegistryKey<DimensionType> dim = player.world.method_27983(); //getDimType
|
||||
RegistryKey<World> dim = player.world.method_27983(); //getDimType
|
||||
switch (option)
|
||||
{
|
||||
case "overworld":
|
||||
dim = DimensionType.OVERWORLD_REGISTRY_KEY;
|
||||
dim = World.field_25179; // OW
|
||||
break;
|
||||
case "nether":
|
||||
dim = DimensionType.THE_NETHER_REGISTRY_KEY;
|
||||
dim = World.field_25180; // nether
|
||||
break;
|
||||
case "end":
|
||||
dim = DimensionType.THE_END_REGISTRY_KEY;
|
||||
dim = World.field_25181; // end
|
||||
break;
|
||||
}
|
||||
return new BaseText[]{SpawnReporter.printMobcapsForDimension(server.getWorld(dim), false).get(0)};
|
||||
|
||||
@@ -14,6 +14,7 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -252,7 +253,7 @@ public class Messenger
|
||||
//message source
|
||||
public static void m(ServerCommandSource source, Object ... fields)
|
||||
{
|
||||
source.sendFeedback(Messenger.c(fields),source.getMinecraftServer() != null && source.getMinecraftServer().getWorld(DimensionType.OVERWORLD_REGISTRY_KEY) != null); //OW
|
||||
source.sendFeedback(Messenger.c(fields),source.getMinecraftServer() != null && source.getMinecraftServer().getWorld(World.field_25179) != null); //OW
|
||||
}
|
||||
public static void m(PlayerEntity player, Object ... fields)
|
||||
{
|
||||
|
||||
@@ -39,19 +39,19 @@ public class SpawnReporter
|
||||
public static boolean mock_spawns = false;
|
||||
|
||||
public static Long track_spawns = 0L;
|
||||
public static final HashMap<RegistryKey<DimensionType>, Integer> chunkCounts = new HashMap<>();
|
||||
public static final HashMap<RegistryKey<World>, Integer> chunkCounts = new HashMap<>();
|
||||
|
||||
public static final HashMap<Pair<RegistryKey<DimensionType>, SpawnGroup>, Object2LongMap<EntityType>> spawn_stats = new HashMap<>();
|
||||
public static final HashMap<Pair<RegistryKey<World>, SpawnGroup>, Object2LongMap<EntityType>> spawn_stats = new HashMap<>();
|
||||
public static double mobcap_exponent = 0.0D;
|
||||
|
||||
public static final HashMap<Pair<RegistryKey<DimensionType>, SpawnGroup>, Long> spawn_attempts = new HashMap<>();
|
||||
public static final HashMap<Pair<RegistryKey<DimensionType>, SpawnGroup>, Long> overall_spawn_ticks = new HashMap<>();
|
||||
public static final HashMap<Pair<RegistryKey<DimensionType>, SpawnGroup>, Long> spawn_ticks_full = new HashMap<>();
|
||||
public static final HashMap<Pair<RegistryKey<DimensionType>, SpawnGroup>, Long> spawn_ticks_fail = new HashMap<>();
|
||||
public static final HashMap<Pair<RegistryKey<DimensionType>, SpawnGroup>, Long> spawn_ticks_succ = new HashMap<>();
|
||||
public static final HashMap<Pair<RegistryKey<DimensionType>, SpawnGroup>, Long> spawn_ticks_spawns = new HashMap<>();
|
||||
public static final HashMap<Pair<RegistryKey<DimensionType>, SpawnGroup>, Long> spawn_cap_count = new HashMap<>();
|
||||
public static final HashMap<Pair<RegistryKey<DimensionType>, SpawnGroup>, EvictingQueue<Pair<EntityType, BlockPos>>> spawned_mobs = new HashMap<>();
|
||||
public static final HashMap<Pair<RegistryKey<World>, SpawnGroup>, Long> spawn_attempts = new HashMap<>();
|
||||
public static final HashMap<Pair<RegistryKey<World>, SpawnGroup>, Long> overall_spawn_ticks = new HashMap<>();
|
||||
public static final HashMap<Pair<RegistryKey<World>, SpawnGroup>, Long> spawn_ticks_full = new HashMap<>();
|
||||
public static final HashMap<Pair<RegistryKey<World>, SpawnGroup>, Long> spawn_ticks_fail = new HashMap<>();
|
||||
public static final HashMap<Pair<RegistryKey<World>, SpawnGroup>, Long> spawn_ticks_succ = new HashMap<>();
|
||||
public static final HashMap<Pair<RegistryKey<World>, SpawnGroup>, Long> spawn_ticks_spawns = new HashMap<>();
|
||||
public static final HashMap<Pair<RegistryKey<World>, SpawnGroup>, Long> spawn_cap_count = new HashMap<>();
|
||||
public static final HashMap<Pair<RegistryKey<World>, SpawnGroup>, EvictingQueue<Pair<EntityType, BlockPos>>> spawned_mobs = new HashMap<>();
|
||||
public static final HashMap<SpawnGroup, Integer> spawn_tries = new HashMap<>();
|
||||
public static BlockPos lower_spawning_limit = null;
|
||||
public static BlockPos upper_spawning_limit = null;
|
||||
@@ -75,7 +75,7 @@ public class SpawnReporter
|
||||
return;
|
||||
}
|
||||
}
|
||||
Pair<RegistryKey<DimensionType>, SpawnGroup> key = Pair.of(mob.world.method_27983(), cat);
|
||||
Pair<RegistryKey<World>, SpawnGroup> key = Pair.of(mob.world.method_27983(), cat);
|
||||
long count = spawn_stats.get(key).getOrDefault(mob.getType(), 0L);
|
||||
spawn_stats.get(key).put(mob.getType(), count + 1);
|
||||
spawned_mobs.get(key).put(Pair.of(mob.getType(), pos));
|
||||
@@ -85,7 +85,7 @@ public class SpawnReporter
|
||||
|
||||
public static List<BaseText> printMobcapsForDimension(ServerWorld world, boolean multiline)
|
||||
{
|
||||
RegistryKey<DimensionType> dim = world.method_27983();
|
||||
RegistryKey<World> dim = world.method_27983();
|
||||
String name = dim.toString();
|
||||
List<BaseText> lst = new ArrayList<>();
|
||||
if (multiline)
|
||||
@@ -305,9 +305,9 @@ public class SpawnReporter
|
||||
{
|
||||
spawn_tries.put(enumcreaturetype, 1);
|
||||
}
|
||||
for (RegistryKey<DimensionType> dim : Arrays.asList(DimensionType.OVERWORLD_REGISTRY_KEY, DimensionType.THE_NETHER_REGISTRY_KEY, DimensionType.THE_END_REGISTRY_KEY))
|
||||
for (RegistryKey<World> dim : Arrays.asList(World.field_25179, World.field_25180, World.field_25181))
|
||||
{
|
||||
Pair<RegistryKey<DimensionType>, SpawnGroup> key = Pair.of(dim, enumcreaturetype);
|
||||
Pair<RegistryKey<World>, SpawnGroup> key = Pair.of(dim, enumcreaturetype);
|
||||
overall_spawn_ticks.put(key, 0L);
|
||||
spawn_attempts.put(key, 0L);
|
||||
spawn_ticks_full.put(key, 0L);
|
||||
|
||||
Reference in new issue
Block a user