This commit is contained in:
gnembon committed 2020-05-21 14:23:04 -03:00
1 parent 42ba5a9f03
commit cf817c2e39
25 files changed
+91 -92

No files matched your search

+1 -1
View File
@@ -5,7 +5,7 @@ org.gradle.jvmargs=-Xmx1G
# check these on https://fabricmc.net/use
# or better: https://modmuss50.me/fabric.html
minecraft_version=20w21a
yarn_mappings=20w21a+build.2
yarn_mappings=20w21a+build.10
loader_version=0.8.4+build.198
# Mod Properties
+2 -2
View File
@@ -530,7 +530,7 @@ public class CarpetSettings
public static class ChangeSpawnChunksValidator extends Validator<Integer> {
public static void changeSpawnSize(int size)
{
ServerWorld overworld = CarpetServer.minecraft_server.getWorld(DimensionType.field_24753); // OW
ServerWorld overworld = CarpetServer.minecraft_server.getWorld(DimensionType.OVERWORLD_REGISTRY_KEY); // OW
if (overworld != null) {
ChunkPos centerChunk = new ChunkPos(new BlockPos(
overworld.getLevelProperties().getSpawnX(),
@@ -551,7 +551,7 @@ public class CarpetSettings
//must been some startup thing
return newValue;
}
ServerWorld currentOverworld = CarpetServer.minecraft_server.getWorld(DimensionType.field_24753); // OW
ServerWorld currentOverworld = CarpetServer.minecraft_server.getWorld(DimensionType.OVERWORLD_REGISTRY_KEY); // OW
if (currentOverworld != null)
{
changeSpawnSize(newValue);
@@ -15,7 +15,6 @@ import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.class_5321;
import net.minecraft.command.arguments.DimensionArgumentType;
import net.minecraft.command.arguments.RotationArgumentType;
import net.minecraft.command.arguments.Vec3ArgumentType;
@@ -27,6 +26,7 @@ import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.math.Direction;
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.dimension.DimensionType;
@@ -235,7 +235,7 @@ public class PlayerCommand
() -> RotationArgumentType.getRotation(context, "direction").toAbsoluteRotation(context.getSource()),
source::getRotation
);
class_5321<DimensionType> dimType = tryGetArg(
RegistryKey<DimensionType> dimType = tryGetArg(
() -> DimensionArgumentType.getDimensionArgument(context, "dimension"),
() -> source.getWorld().method_27983() // dimension.getType()
);
@@ -11,7 +11,6 @@ import com.mojang.brigadier.arguments.BoolArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
import net.minecraft.class_5321;
import net.minecraft.command.arguments.BlockPosArgumentType;
import net.minecraft.command.arguments.DimensionArgumentType;
import net.minecraft.entity.SpawnGroup;
@@ -19,6 +18,7 @@ import net.minecraft.entity.player.PlayerEntity;
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.dimension.DimensionType;
import java.util.Arrays;
@@ -258,7 +258,7 @@ public class SpawnCommand
return 1;
}
private static int mobcapsForDimension(ServerCommandSource source, class_5321<DimensionType> dim)
private static int mobcapsForDimension(ServerCommandSource source, RegistryKey<DimensionType> dim)
{
Messenger.send(source, SpawnReporter.printMobcapsForDimension(source.getMinecraftServer().getWorld(dim), true));
return 1;
@@ -50,7 +50,7 @@ public class HopperCounter
{
if (startTick == 0)
{
startTick = server.getWorld(DimensionType.field_24753).getTime(); //OW
startTick = server.getWorld(DimensionType.OVERWORLD_REGISTRY_KEY).getTime(); //OW
startMillis = System.currentTimeMillis();
}
Item item = stack.getItem();
@@ -61,7 +61,7 @@ public class HopperCounter
public void reset(MinecraftServer server)
{
counter.clear();
startTick = server.getWorld(DimensionType.field_24753).getTime(); //OW
startTick = server.getWorld(DimensionType.OVERWORLD_REGISTRY_KEY).getTime(); //OW
startMillis = System.currentTimeMillis();
// pubSubProvider.publish();
}
@@ -105,7 +105,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.field_24753).getTime() - startTick, 1); //OW
long ticks = Math.max(realTime ? (System.currentTimeMillis() - startMillis) / 50 : server.getWorld(DimensionType.OVERWORLD_REGISTRY_KEY).getTime() - startTick, 1); //OW
if (total == 0)
{
if (brief)
@@ -1,10 +1,10 @@
package carpet.mixins;
import carpet.CarpetSettings;
import net.minecraft.class_5321;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Box;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.dimension.DimensionType;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@@ -22,7 +22,7 @@ public abstract class Entity_portalSuffocationMixin
value = "INVOKE",
target = "Lnet/minecraft/entity/Entity;getLastNetherPortalDirection()Lnet/minecraft/util/math/Direction;"
))
private void registerEntityDimensionChange(class_5321<DimensionType> newDimension, CallbackInfoReturnable<Entity> cir)
private void registerEntityDimensionChange(RegistryKey<DimensionType> newDimension, CallbackInfoReturnable<Entity> cir)
{
if (CarpetSettings.portalSuffocationFix)
{
@@ -44,7 +44,7 @@ public abstract class Entity_portalSuffocationMixin
}
@Inject(method = "changeDimension", at = @At("RETURN"))
private void removeEntity(class_5321<DimensionType> newDimension, CallbackInfoReturnable<Entity> cir)
private void removeEntity(RegistryKey<DimensionType> newDimension, CallbackInfoReturnable<Entity> cir)
{
CarpetSettings.currentTelepotingEntityBox = null;
CarpetSettings.fixedPosition = null;
@@ -3,14 +3,14 @@ package carpet.mixins;
import carpet.fakes.ServerChunkManagerInterface;
import carpet.utils.SpawnReporter;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import net.minecraft.class_5217;
import net.minecraft.class_5321;
import net.minecraft.entity.SpawnGroup;
import net.minecraft.server.world.ChunkTicketManager;
import net.minecraft.server.world.ServerChunkManager;
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.WorldProperties;
import net.minecraft.world.chunk.WorldChunk;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.level.LevelProperties;
@@ -48,7 +48,7 @@ public abstract class ServerChunkManagerMixin implements ServerChunkManagerInter
private int setupTracking(ChunkTicketManager chunkTicketManager)
{
int j = chunkTicketManager.getSpawningChunkCount();
class_5321<DimensionType> dim = this.world.method_27983(); // getDimensionType;
RegistryKey<DimensionType> dim = this.world.method_27983(); // getDimensionType;
//((WorldInterface)world).getPrecookedMobs().clear(); not needed because mobs are compared with predefined BBs
SpawnReporter.chunkCounts.put(dim, j);
@@ -72,13 +72,13 @@ public abstract class ServerChunkManagerMixin implements ServerChunkManagerInter
@Inject(method = "tickChunks", at = @At("RETURN"))
private void onFinishSpawnWorldCycle(CallbackInfo ci)
{
class_5217 levelProperties_1 = this.world.getLevelProperties(); // levelProperies class
WorldProperties levelProperties_1 = this.world.getLevelProperties(); // levelProperies class
boolean boolean_3 = levelProperties_1.getTime() % 400L == 0L;
if (SpawnReporter.track_spawns > 0L && SpawnReporter.local_spawns != null)
{
for (SpawnGroup cat: SpawnGroup.values())
{
class_5321<DimensionType> dim = world.method_27983(); // getDimensionType;
RegistryKey<DimensionType> dim = world.method_27983(); // getDimensionType;
Pair key = Pair.of(dim, cat);
int spawnTries = SpawnReporter.spawn_tries.get(cat);
if (!SpawnReporter.local_spawns.containsKey(cat))
@@ -93,12 +93,12 @@ public abstract class ServerChunkManager_tickMixin
value = "INVOKE",
//target = "Lnet/minecraft/world/level/LevelProperties;getGeneratorType()Lnet/minecraft/world/level/LevelGeneratorType;"
//target = "Lnet/minecraft/class_5217;getGeneratorType()Lnet/minecraft/world/level/LevelGeneratorType;"
target = "Lnet/minecraft/server/world/ServerWorld;method_27982()Z" // idDebug
target = "Lnet/minecraft/server/world/ServerWorld;isDebugWorld()Z" // idDebug
))
private boolean skipChunkTicking(ServerWorld serverWorld)
{
if (!TickSpeed.process_entities) return true;
return serverWorld.method_27982(); //isDebug
return serverWorld.isDebugWorld();
}
}
@@ -3,7 +3,6 @@ package carpet.mixins;
import carpet.fakes.EntityInterface;
import carpet.script.EntityEventsGroup;
import com.mojang.authlib.GameProfile;
import net.minecraft.class_5321;
import net.minecraft.entity.Entity;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.player.PlayerEntity;
@@ -13,6 +12,7 @@ import net.minecraft.stat.Stat;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.World;
import net.minecraft.world.dimension.DimensionType;
import org.spongepowered.asm.mixin.Mixin;
@@ -89,23 +89,23 @@ public abstract class ServerPlayerEntity_scarpetEventMixin extends PlayerEntity
}
private Vec3d previousLocation;
private class_5321<DimensionType> previousDimension;
private RegistryKey<DimensionType> previousDimension;
@Inject(method = "changeDimension", at = @At("HEAD"))
private void logPreviousCoordinates(class_5321<DimensionType> newDimension, CallbackInfoReturnable<Entity> cir)
private void logPreviousCoordinates(RegistryKey<DimensionType> newDimension, CallbackInfoReturnable<Entity> cir)
{
previousLocation = getPos();
previousDimension = world.method_27983(); //dimension type
}
@Inject(method = "changeDimension", at = @At("RETURN"))
private void atChangeDimension(class_5321<DimensionType> newDimension, CallbackInfoReturnable<Entity> cir)
private void atChangeDimension(RegistryKey<DimensionType> newDimension, CallbackInfoReturnable<Entity> cir)
{
if (PLAYER_CHANGES_DIMENSION.isNeeded())
{
ServerPlayerEntity player = (ServerPlayerEntity) (Object)this;
Vec3d to = null;
if (!notInAnyWorld || previousDimension != DimensionType.field_24755 || newDimension != DimensionType.field_24753) // end ow
if (!notInAnyWorld || previousDimension != DimensionType.THE_END_REGISTRY_KEY || newDimension != DimensionType.OVERWORLD_REGISTRY_KEY) // end ow
{
to = getPos();
}
@@ -2,10 +2,10 @@ package carpet.mixins;
import carpet.helpers.TickSpeed;
import carpet.utils.CarpetProfiler;
import net.minecraft.class_5269;
import net.minecraft.entity.raid.RaidManager;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.profiler.Profiler;
import net.minecraft.world.MutableWorldProperties;
import net.minecraft.world.WanderingTraderManager;
import net.minecraft.world.World;
import net.minecraft.world.border.WorldBorder;
@@ -28,10 +28,9 @@ public abstract class ServerWorld_tickMixin extends World
//@Shadow protected abstract void sendBlockActions();
@Shadow protected abstract void method_29203();
protected ServerWorld_tickMixin(class_5269 arg, DimensionType dimensionType, Supplier<Profiler> supplier, boolean bl, boolean bl2, long l)
protected ServerWorld_tickMixin(MutableWorldProperties mutableWorldProperties, DimensionType dimensionType, Supplier<Profiler> supplier, boolean bl, boolean bl2, long l)
{
super(arg, dimensionType, supplier, bl, bl2, l);
super(mutableWorldProperties, dimensionType, supplier, bl, bl2, l);
}
private CarpetProfiler.ProfilerToken currentSection;
@@ -149,13 +148,13 @@ public abstract class ServerWorld_tickMixin extends World
@Redirect(method = "tick", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/server/world/ServerWorld;method_27982()Z" // isDebug
target = "Lnet/minecraft/server/world/ServerWorld;isDebugWorld()Z" // isDebug
//target = "Lnet/minecraft/world/level/LevelProperties;getGeneratorType()Lnet/minecraft/world/level/LevelGeneratorType;"
))
private boolean tickPendingBlocks(ServerWorld serverWorld)
{
if (!TickSpeed.process_entities) return true;
return serverWorld.method_27982(); // isDebug()
return serverWorld.isDebugWorld(); // isDebug()
}
@Redirect(method = "tick", at = @At(
@@ -6,7 +6,6 @@ import carpet.utils.SpawnReporter;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.FenceGateBlock;
import net.minecraft.class_5321;
import net.minecraft.entity.Entity;
import net.minecraft.entity.SpawnGroup;
import net.minecraft.entity.EntityData;
@@ -20,6 +19,7 @@ import net.minecraft.tag.BlockTags;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.WorldAccess;
@@ -281,7 +281,7 @@ public class SpawnHelperMixin
SpawnGroup entityCategory = var6[var8];
if ((spawnAnimals || !entityCategory.isPeaceful()) && (spawnMonsters || entityCategory.isPeaceful()) && (shouldSpawnAnimals || !entityCategory.isAnimal()) )
{
class_5321<DimensionType> dim = world.method_27983(); // getDimensionType;
RegistryKey<DimensionType> 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
@@ -1,7 +1,7 @@
package carpet.mixins;
import carpet.CarpetSettings;
import net.minecraft.class_5294;
import net.minecraft.client.render.SkyProperties;
import net.minecraft.client.render.WorldRenderer;
//import net.minecraft.world.dimension.Dimension;
import org.spongepowered.asm.mixin.Mixin;
@@ -13,12 +13,12 @@ public class WorldRenderer_fogOffMixin
{
@Redirect(method = "render", require = 0, expect = 0, at = @At(
value = "INVOKE",
target = "Lnet/minecraft/class_5294;method_28110(II)Z" //method_28110 isFogThick
target = "Lnet/minecraft/client/render/SkyProperties;useThickFog(II)Z" //method_28110 isFogThick
))
private boolean isReallyThick(class_5294 class_5294, int x, int z)
private boolean isReallyThick(SkyProperties skyProperties, int x, int z)
{
if (CarpetSettings.fogOff) return false;
return class_5294.method_28110(x, z); //isFogThick
return skyProperties.useThickFog(x, z); //isFogThick
}
}
@@ -6,11 +6,11 @@ import net.minecraft.block.Block;
import net.minecraft.block.BlockEntityProvider;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.class_5269;
import net.minecraft.server.world.ChunkHolder;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.profiler.Profiler;
import net.minecraft.world.BlockView;
import net.minecraft.world.MutableWorldProperties;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.World;
import net.minecraft.world.chunk.EmptyChunk;
@@ -27,7 +27,7 @@ public abstract class World_movableTEMixin implements WorldInterface, WorldAcces
public boolean isClient;
@Shadow
@Final
protected class_5269 properties; //LevelProperties
protected MutableWorldProperties properties; //LevelProperties
@Shadow
public abstract WorldChunk getWorldChunk(BlockPos blockPos_1);
@@ -56,7 +56,7 @@ public abstract class World_movableTEMixin implements WorldInterface, WorldAcces
@Shadow public abstract boolean setBlockState(BlockPos pos, BlockState state, int flags);
@Shadow public abstract boolean method_27982(); //isDebug()
@Shadow public abstract boolean isDebugWorld();
/**
* @author 2No2Name
@@ -70,7 +70,7 @@ public abstract class World_movableTEMixin implements WorldInterface, WorldAcces
{
return false;
}
else if (!this.isClient && method_27982())
else if (!this.isClient && isDebugWorld())
{
return false;
}
@@ -2,7 +2,6 @@ package carpet.patches;
import com.mojang.authlib.GameProfile;
import net.minecraft.block.entity.SkullBlockEntity;
import net.minecraft.class_5321;
import net.minecraft.network.packet.s2c.play.EntityPositionS2CPacket;
import net.minecraft.network.packet.s2c.play.EntitySetHeadYawS2CPacket;
import net.minecraft.network.packet.s2c.play.PlayerListS2CPacket;
@@ -15,6 +14,7 @@ import net.minecraft.server.ServerTask;
import net.minecraft.server.network.ServerPlayerEntity;
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.dimension.DimensionType;
import carpet.fakes.ServerPlayerEntityInterface;
@@ -26,7 +26,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, class_5321<DimensionType> dimensionId, GameMode gamemode)
public static EntityPlayerMPFake createFake(String username, MinecraftServer server, double d0, double d1, double d2, double yaw, double pitch, RegistryKey<DimensionType> dimensionId, GameMode gamemode)
{
//prolly half of that crap is not necessary, but it works
ServerWorld worldIn = server.getWorld(dimensionId);
@@ -12,7 +12,6 @@ import carpet.script.value.StringValue;
import carpet.script.value.Value;
import carpet.utils.Messenger;
import net.minecraft.block.BlockState;
import net.minecraft.class_5321;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.entity.Entity;
@@ -29,6 +28,7 @@ import net.minecraft.util.math.ChunkPos;
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.chunk.Chunk;
import net.minecraft.world.dimension.DimensionType;
import org.apache.commons.lang3.tuple.Pair;
@@ -191,7 +191,7 @@ public class CarpetEventServer
{
handler.call(Collections::emptyList, () ->
CarpetServer.minecraft_server.getCommandSource().
withWorld(CarpetServer.minecraft_server.getWorld(DimensionType.field_24753))// OVERWORLD))
withWorld(CarpetServer.minecraft_server.getWorld(DimensionType.OVERWORLD_REGISTRY_KEY))
);
}
},
@@ -202,7 +202,7 @@ public class CarpetEventServer
{
handler.call(Collections::emptyList, () ->
CarpetServer.minecraft_server.getCommandSource().
withWorld(CarpetServer.minecraft_server.getWorld(DimensionType.field_24754))// THE_NETHER))
withWorld(CarpetServer.minecraft_server.getWorld(DimensionType.THE_NETHER_REGISTRY_KEY))
);
}
},
@@ -213,7 +213,7 @@ public class CarpetEventServer
{
handler.call(Collections::emptyList, () ->
CarpetServer.minecraft_server.getCommandSource().
withWorld(CarpetServer.minecraft_server.getWorld(DimensionType.field_24755))//THE_END))
withWorld(CarpetServer.minecraft_server.getWorld(DimensionType.THE_END_REGISTRY_KEY))
);
}
},
@@ -531,13 +531,13 @@ public class CarpetEventServer
PLAYER_CHANGES_DIMENSION("player_changes_dimension", 5, false)
{
@Override
public void onDimensionChange(ServerPlayerEntity player, Vec3d from, Vec3d to, class_5321<DimensionType> fromDim, class_5321<DimensionType> dimTo)
public void onDimensionChange(ServerPlayerEntity player, Vec3d from, Vec3d to, RegistryKey<DimensionType> fromDim, RegistryKey<DimensionType> dimTo)
{
// eligibility already checked in mixin
Value fromValue = ListValue.fromTriple(from.x, from.y, from.z);
Value toValue = (to == null)?Value.NULL:ListValue.fromTriple(to.x, to.y, to.z);
Value fromDimStr = new StringValue(NBTSerializableValue.nameFromRegistryId(fromDim.method_29177()));
Value toDimStr = new StringValue(NBTSerializableValue.nameFromRegistryId(dimTo.method_29177()));
Value fromDimStr = new StringValue(NBTSerializableValue.nameFromRegistryId(fromDim.getValue()));
Value toDimStr = new StringValue(NBTSerializableValue.nameFromRegistryId(dimTo.getValue()));
handler.call( () -> Arrays.asList(
((c, t) -> new EntityValue(player)),
@@ -620,7 +620,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, class_5321<DimensionType> fromDim, class_5321<DimensionType> dimTo) {}
public void onDimensionChange(ServerPlayerEntity player, Vec3d from, Vec3d to, RegistryKey<DimensionType> fromDim, RegistryKey<DimensionType> dimTo) {}
public void onDamage(Entity target, float amount, DamageSource source) { }
@@ -2998,7 +2998,7 @@ public class CarpetExpression
this.expr.addLazyFunction("current_dimension", 0, (c, t, lv) -> {
ServerCommandSource s = ((CarpetContext)c).s;
Value retval = new StringValue(NBTSerializableValue.nameFromRegistryId(s.getWorld().method_27983().method_29177())); // getDImensionType
Value retval = new StringValue(NBTSerializableValue.nameFromRegistryId(s.getWorld().method_27983().getValue())); // getDImensionType
return (cc, tt) -> retval;
});
@@ -3029,15 +3029,15 @@ public class CarpetExpression
{
case "nether":
case "the_nether":
innerSource = outerSource.withWorld(outerSource.getMinecraftServer().getWorld(DimensionType.field_24754));
innerSource = outerSource.withWorld(outerSource.getMinecraftServer().getWorld(DimensionType.THE_NETHER_REGISTRY_KEY));
break;
case "end":
case "the_end":
innerSource = outerSource.withWorld(outerSource.getMinecraftServer().getWorld(DimensionType.field_24755));
innerSource = outerSource.withWorld(outerSource.getMinecraftServer().getWorld(DimensionType.THE_END_REGISTRY_KEY));
break;
case "overworld":
case "over_world":
innerSource = outerSource.withWorld(outerSource.getMinecraftServer().getWorld(DimensionType.field_24753));
innerSource = outerSource.withWorld(outerSource.getMinecraftServer().getWorld(DimensionType.OVERWORLD_REGISTRY_KEY));
break;
default:
throw new InternalExpressionException("Incorrect dimension string: "+dimString);
@@ -15,8 +15,8 @@ import carpet.utils.Messenger;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.tree.CommandNode;
import net.minecraft.class_5218;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.util.WorldSavePath;
import net.minecraft.util.math.BlockPos;
import java.io.File;
@@ -76,7 +76,7 @@ public class CarpetScriptServer
public Module getModule(String name, boolean allowLibraries)
{
File folder = CarpetServer.minecraft_server.method_27050(class_5218.field_24188).resolve("scripts").toFile();
File folder = CarpetServer.minecraft_server.method_27050(WorldSavePath.ROOT).resolve("scripts").toFile();
File[] listOfFiles = folder.listFiles();
if (listOfFiles != null)
for (File script : listOfFiles)
@@ -110,7 +110,7 @@ public class CarpetScriptServer
if (!mi.isLibrary()) moduleNames.add(mi.getName());
}
}
File folder = CarpetServer.minecraft_server.method_27050(class_5218.field_24188).resolve("scripts").toFile();
File folder = CarpetServer.minecraft_server.method_27050(WorldSavePath.ROOT).resolve("scripts").toFile();
File[] listOfFiles = folder.listFiles();
if (listOfFiles == null)
return moduleNames;
@@ -1,8 +1,8 @@
package carpet.script.bundled;
import carpet.CarpetServer;
import net.minecraft.class_5218;
import net.minecraft.nbt.Tag;
import net.minecraft.util.WorldSavePath;
import java.io.File;
import java.nio.file.Files;
@@ -35,7 +35,7 @@ public abstract class Module
public static Tag getData(Module module, String file, boolean isShared)
{
if (!isShared && (module == null || module.getName() == null)) return null;
File dataFile = CarpetServer.minecraft_server.method_27050(class_5218.field_24188).resolve("scripts/"+getDescriptor(module, file, isShared)+".nbt").toFile();
File dataFile = CarpetServer.minecraft_server.method_27050(WorldSavePath.ROOT).resolve("scripts/"+getDescriptor(module, file, isShared)+".nbt").toFile();
if (!Files.exists(dataFile.toPath()) || !(dataFile.isFile())) return null;
return read(dataFile);
}
@@ -43,7 +43,7 @@ public abstract class Module
public static boolean saveData(Module module, String file, Tag globalState, boolean isShared)
{
if (!isShared && (module == null || module.getName() == null)) return false;
File dataFile =CarpetServer.minecraft_server.method_27050(class_5218.field_24188).resolve("scripts/"+getDescriptor(module, file, isShared)+".nbt").toFile();
File dataFile =CarpetServer.minecraft_server.method_27050(WorldSavePath.ROOT).resolve("scripts/"+getDescriptor(module, file, isShared)+".nbt").toFile();
if (!Files.exists(dataFile.toPath().getParent()) && !dataFile.getParentFile().mkdirs()) return false;
return write(globalState, dataFile);
}
@@ -249,7 +249,7 @@ public class EntityValue extends Value
put("immune_to_fire", (e, a) -> new NumericValue(e.isFireImmune()));
put("invulnerable", (e, a) -> new NumericValue(e.isInvulnerable()));
put("dimension", (e, a) -> new StringValue(nameFromRegistryId(e.world.method_27983().method_29177()))); // getDimId
put("dimension", (e, a) -> new StringValue(nameFromRegistryId(e.world.method_27983().getValue()))); // getDimId
put("height", (e, a) -> new NumericValue(e.getDimensions(EntityPose.STANDING).height));
put("width", (e, a) -> new NumericValue(e.getDimensions(EntityPose.STANDING).width));
put("eye_height", (e, a) -> new NumericValue(e.getStandingEyeHeight()));
@@ -12,13 +12,13 @@ import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
import net.minecraft.class_5218;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.ServerTask;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.BaseText;
import net.minecraft.util.WorldSavePath;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.logging.log4j.util.TriConsumer;
@@ -139,7 +139,7 @@ public class SettingsManager
private File getFile()
{
return server.method_27050(class_5218.field_24188).resolve(identifier+".conf").toFile();
return server.method_27050(WorldSavePath.ROOT).resolve(identifier+".conf").toFile();
}
public void disableBooleanCommands()
+1 -1
View File
@@ -175,7 +175,7 @@ public class BlockInfo
Material material = state.getMaterial();
Block block = state.getBlock();
String metastring = "";
for (net.minecraft.state.property.Property<?> iproperty : state.method_28501())// getProperties())
for (net.minecraft.state.property.Property<?> iproperty : state.getProperties())
{
metastring += ", "+iproperty.getName() + '='+state.get(iproperty);
}
@@ -56,7 +56,7 @@ public class CarpetProfiler
private static String getSectionString(World world, String section)
{
return String.format("%s.%s%s",
world.method_27983().method_29177().toString().replaceFirst("minecraft:", ""),
world.method_27983().getValue().toString().replaceFirst("minecraft:", ""),
section, // ^ getDImension getId
world.isClient ? " (Client)" : "");
}
@@ -64,7 +64,7 @@ public class CarpetProfiler
private static String getEntityString(World world, Entity e)
{
return String.format("%s.%s%s",
world.method_27983().method_29177().toString().replaceFirst("minecraft:", ""),
world.method_27983().getValue().toString().replaceFirst("minecraft:", ""),
Registry.ENTITY_TYPE.getId(e.getType()).toString().replaceFirst("minecraft:", ""),
world.isClient ? " (Client)" : "");
}
@@ -72,7 +72,7 @@ public class CarpetProfiler
private static String getTEntityString(World world, BlockEntity be)
{
return String.format("%s.%s%s",
world.method_27983().method_29177().toString().replaceFirst("minecraft:", ""),
world.method_27983().getValue().toString().replaceFirst("minecraft:", ""),
Registry.BLOCK_ENTITY_TYPE.getId(be.getType()).toString().replaceFirst("minecraft:", ""),
world.isClient ? " (Client)" : "");
}
@@ -5,7 +5,6 @@ import carpet.helpers.TickSpeed;
import carpet.logging.LoggerRegistry;
import carpet.logging.logHelpers.PacketCounter;
import carpet.mixins.PlayerListHeaderS2CPacketMixin;
import net.minecraft.class_5321;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.network.packet.s2c.play.PlayerListHeaderS2CPacket;
@@ -13,6 +12,7 @@ import net.minecraft.server.MinecraftServer;
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.dimension.DimensionType;
import java.util.ArrayList;
@@ -59,17 +59,17 @@ public class HUDController
if (LoggerRegistry.__mobcaps)
LoggerRegistry.getLogger("mobcaps").log((option, player) -> {
class_5321<DimensionType> dim = player.world.method_27983(); //getDimType
RegistryKey<DimensionType> dim = player.world.method_27983(); //getDimType
switch (option)
{
case "overworld":
dim = DimensionType.field_24753; // OW
dim = DimensionType.OVERWORLD_REGISTRY_KEY;
break;
case "nether":
dim = DimensionType.field_24754; // nrther
dim = DimensionType.THE_NETHER_REGISTRY_KEY;
break;
case "end":
dim = DimensionType.field_24755; // end
dim = DimensionType.THE_END_REGISTRY_KEY;
break;
}
return new BaseText[]{SpawnReporter.printMobcapsForDimension(server.getWorld(dim), false).get(0)};
+1 -1
View File
@@ -252,7 +252,7 @@ public class Messenger
//message source
public static void m(ServerCommandSource source, Object ... fields)
{
source.sendFeedback(Messenger.c(fields),source.getMinecraftServer().getWorld(DimensionType.field_24753) != null); //OW
source.sendFeedback(Messenger.c(fields),source.getMinecraftServer().getWorld(DimensionType.OVERWORLD_REGISTRY_KEY) != null); //OW
}
public static void m(PlayerEntity player, Object ... fields)
{
+18 -18
View File
@@ -5,7 +5,6 @@ import carpet.mixins.WeightedPickerEntryMixin;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2LongMap;
import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap;
import net.minecraft.class_5321;
import net.minecraft.entity.Entity;
import net.minecraft.entity.SpawnGroup;
import net.minecraft.entity.EntityType;
@@ -19,6 +18,7 @@ import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.DyeColor;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.Heightmap;
import net.minecraft.world.SpawnHelper;
import net.minecraft.world.World;
@@ -39,19 +39,19 @@ public class SpawnReporter
public static boolean mock_spawns = false;
public static Long track_spawns = 0L;
public static final HashMap<class_5321<DimensionType>, Integer> chunkCounts = new HashMap<>();
public static final HashMap<RegistryKey<DimensionType>, Integer> chunkCounts = new HashMap<>();
public static final HashMap<Pair<class_5321<DimensionType>, SpawnGroup>, Object2LongMap<EntityType>> spawn_stats = new HashMap<>();
public static final HashMap<Pair<RegistryKey<DimensionType>, SpawnGroup>, Object2LongMap<EntityType>> spawn_stats = new HashMap<>();
public static double mobcap_exponent = 0.0D;
public static final HashMap<Pair<class_5321<DimensionType>, SpawnGroup>, Long> spawn_attempts = new HashMap<>();
public static final HashMap<Pair<class_5321<DimensionType>, SpawnGroup>, Long> overall_spawn_ticks = new HashMap<>();
public static final HashMap<Pair<class_5321<DimensionType>, SpawnGroup>, Long> spawn_ticks_full = new HashMap<>();
public static final HashMap<Pair<class_5321<DimensionType>, SpawnGroup>, Long> spawn_ticks_fail = new HashMap<>();
public static final HashMap<Pair<class_5321<DimensionType>, SpawnGroup>, Long> spawn_ticks_succ = new HashMap<>();
public static final HashMap<Pair<class_5321<DimensionType>, SpawnGroup>, Long> spawn_ticks_spawns = new HashMap<>();
public static final HashMap<Pair<class_5321<DimensionType>, SpawnGroup>, Long> spawn_cap_count = new HashMap<>();
public static final HashMap<Pair<class_5321<DimensionType>, SpawnGroup>, EvictingQueue<Pair<EntityType, BlockPos>>> spawned_mobs = new HashMap<>();
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<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<class_5321<DimensionType>, SpawnGroup> key = Pair.of(mob.world.method_27983(), cat);
Pair<RegistryKey<DimensionType>, 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)
{
class_5321<DimensionType> dim = world.method_27983();
RegistryKey<DimensionType> 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 (class_5321<DimensionType> dim : Arrays.asList(DimensionType.field_24753, DimensionType.field_24754, DimensionType.field_24755))
for (RegistryKey<DimensionType> dim : Arrays.asList(DimensionType.OVERWORLD_REGISTRY_KEY, DimensionType.THE_NETHER_REGISTRY_KEY, DimensionType.THE_END_REGISTRY_KEY))
{
Pair<class_5321<DimensionType>, SpawnGroup> key = Pair.of(dim, enumcreaturetype);
Pair<RegistryKey<DimensionType>, SpawnGroup> key = Pair.of(dim, enumcreaturetype);
overall_spawn_ticks.put(key, 0L);
spawn_attempts.put(key, 0L);
spawn_ticks_full.put(key, 0L);
@@ -345,15 +345,15 @@ public class SpawnReporter
{
//String type_code = String.format("%s", enumcreaturetype);
boolean there_are_mobs_to_list = false;
for (class_5321<DimensionType> dim: Arrays.asList(DimensionType.field_24753, DimensionType.field_24754, DimensionType.field_24755)) //String world_code: new String[] {"", " (N)", " (E)"})
for (RegistryKey<DimensionType> dim: Arrays.asList(DimensionType.OVERWORLD_REGISTRY_KEY, DimensionType.THE_NETHER_REGISTRY_KEY, DimensionType.THE_END_REGISTRY_KEY)) //String world_code: new String[] {"", " (N)", " (E)"})
{
Pair<class_5321<DimensionType>, SpawnGroup> code = Pair.of(dim, enumcreaturetype);
Pair<RegistryKey<DimensionType>, SpawnGroup> code = Pair.of(dim, enumcreaturetype);
if (spawn_ticks_spawns.get(code) > 0L)
{
there_are_mobs_to_list = true;
double hours = overall_spawn_ticks.get(code)/72000.0;
report.add(Messenger.s(String.format(" > %s (%.1f min), %.1f m/t, {%.1f%%F / %.1f%%- / %.1f%%+}; %.2f s/att",
code.getRight()+((code.getLeft()==DimensionType.field_24753)?"":( (code.getLeft()==DimensionType.field_24754)?"(N)":"(E)" )), // OW, nether
code.getRight()+((code.getLeft()==DimensionType.OVERWORLD_REGISTRY_KEY)?"":( (code.getLeft()==DimensionType.THE_NETHER_REGISTRY_KEY)?"(N)":"(E)" )), // OW, nether
60*hours,
(1.0D*spawn_cap_count.get(code))/ spawn_attempts.get(code),
(100.0D*spawn_ticks_full.get(code))/ spawn_attempts.get(code),