Migrate the Carpet codebase to Mojang Mappings
This commit is contained in:
346 files changed
+8353
-8492
No files matched your search
@@ -8,19 +8,19 @@ import carpet.settings.Validator;
|
||||
import carpet.utils.Translations;
|
||||
import carpet.utils.Messenger;
|
||||
import carpet.utils.SpawnChunks;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.server.dedicated.DedicatedServer;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.server.ServerInterface;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@@ -55,7 +55,7 @@ public class CarpetSettings
|
||||
public static int updateSuppressionBlockSetting = -1;
|
||||
|
||||
private static class LanguageValidator extends Validator<String> {
|
||||
@Override public String validate(ServerCommandSource source, ParsedRule<String> currentRule, String newValue, String string) {
|
||||
@Override public String validate(CommandSourceStack source, ParsedRule<String> currentRule, String newValue, String string) {
|
||||
if (currentRule.get().equals(newValue) || source == null)
|
||||
{
|
||||
return newValue;
|
||||
@@ -128,8 +128,8 @@ public class CarpetSettings
|
||||
*/
|
||||
|
||||
private static class CarpetPermissionLevel extends Validator<String> {
|
||||
@Override public String validate(ServerCommandSource source, ParsedRule<String> currentRule, String newValue, String string) {
|
||||
if (source == null || source.hasPermissionLevel(4))
|
||||
@Override public String validate(CommandSourceStack source, ParsedRule<String> currentRule, String newValue, String string) {
|
||||
if (source == null || source.hasPermission(4))
|
||||
return newValue;
|
||||
return null;
|
||||
}
|
||||
@@ -173,7 +173,7 @@ public class CarpetSettings
|
||||
|
||||
|
||||
private static class OneHourMaxDelayLimit extends Validator<Integer> {
|
||||
@Override public Integer validate(ServerCommandSource source, ParsedRule<Integer> currentRule, Integer newValue, String string) {
|
||||
@Override public Integer validate(CommandSourceStack source, ParsedRule<Integer> currentRule, Integer newValue, String string) {
|
||||
return (newValue > 0 && newValue <= 72000) ? newValue : null;
|
||||
}
|
||||
@Override
|
||||
@@ -208,7 +208,7 @@ public class CarpetSettings
|
||||
public static class StackableShulkerBoxValidator extends Validator<String>
|
||||
{
|
||||
@Override
|
||||
public String validate(ServerCommandSource source, ParsedRule<String> currentRule, String newValue, String string)
|
||||
public String validate(CommandSourceStack source, ParsedRule<String> currentRule, String newValue, String string)
|
||||
{
|
||||
if (newValue.matches("^[0-9]+$")) {
|
||||
int value = Integer.parseInt(newValue);
|
||||
@@ -258,7 +258,7 @@ public class CarpetSettings
|
||||
private static class CheckOptimizedTntEnabledValidator<T> extends Validator<T>
|
||||
{
|
||||
@Override
|
||||
public T validate(ServerCommandSource source, ParsedRule<T> currentRule, T newValue, String string) {
|
||||
public T validate(CommandSourceStack source, ParsedRule<T> currentRule, T newValue, String string) {
|
||||
return optimizedTNT || currentRule.defaultValue.equals(newValue) ? newValue : null;
|
||||
}
|
||||
|
||||
@@ -274,7 +274,7 @@ public class CarpetSettings
|
||||
|
||||
private static class TNTRandomRangeValidator extends Validator<Double> {
|
||||
@Override
|
||||
public Double validate(ServerCommandSource source, ParsedRule<Double> currentRule, Double newValue, String string) {
|
||||
public Double validate(CommandSourceStack source, ParsedRule<Double> currentRule, Double newValue, String string) {
|
||||
return newValue == -1 || newValue >= 0 ? newValue : null;
|
||||
}
|
||||
|
||||
@@ -290,7 +290,7 @@ public class CarpetSettings
|
||||
|
||||
private static class TNTAngleValidator extends Validator<Double> {
|
||||
@Override
|
||||
public Double validate(ServerCommandSource source, ParsedRule<Double> currentRule, Double newValue, String string) {
|
||||
public Double validate(CommandSourceStack source, ParsedRule<Double> currentRule, Double newValue, String string) {
|
||||
return (newValue >= 0 && newValue < Math.PI * 2) || newValue == -1 ? newValue : null;
|
||||
}
|
||||
|
||||
@@ -384,7 +384,7 @@ public class CarpetSettings
|
||||
|
||||
|
||||
private static class ChainStoneSetting extends Validator<String> {
|
||||
@Override public String validate(ServerCommandSource source, ParsedRule<String> currentRule, String newValue, String string) {
|
||||
@Override public String validate(CommandSourceStack source, ParsedRule<String> currentRule, String newValue, String string) {
|
||||
CarpetSettings.doChainStone = !newValue.toLowerCase(Locale.ROOT).equals("false");
|
||||
CarpetSettings.chainStoneStickToAll = newValue.toLowerCase(Locale.ROOT).equals("stick_to_all");
|
||||
|
||||
@@ -481,9 +481,9 @@ public class CarpetSettings
|
||||
public static String commandScript = "true";
|
||||
|
||||
private static class ModulePermissionLevel extends Validator<String> {
|
||||
@Override public String validate(ServerCommandSource source, ParsedRule<String> currentRule, String newValue, String string) {
|
||||
@Override public String validate(CommandSourceStack source, ParsedRule<String> currentRule, String newValue, String string) {
|
||||
int permissionLevel = SettingsManager.getCommandLevel(newValue);
|
||||
if (source != null && !source.hasPermissionLevel(permissionLevel))
|
||||
if (source != null && !source.hasPermission(permissionLevel))
|
||||
return null;
|
||||
CarpetSettings.runPermissionLevel = permissionLevel;
|
||||
CarpetServer.settingsManager.notifyPlayersCommandsChanged();
|
||||
@@ -581,7 +581,7 @@ public class CarpetSettings
|
||||
//public static boolean miningGhostBlockFix = false;
|
||||
|
||||
private static class PushLimitLimits extends Validator<Integer> {
|
||||
@Override public Integer validate(ServerCommandSource source, ParsedRule<Integer> currentRule, Integer newValue, String string) {
|
||||
@Override public Integer validate(CommandSourceStack source, ParsedRule<Integer> currentRule, Integer newValue, String string) {
|
||||
return (newValue>0 && newValue <= 1024) ? newValue : null;
|
||||
}
|
||||
@Override
|
||||
@@ -606,7 +606,7 @@ public class CarpetSettings
|
||||
public static int railPowerLimit = 9;
|
||||
|
||||
private static class FillLimitLimits extends Validator<Integer> {
|
||||
@Override public Integer validate(ServerCommandSource source, ParsedRule<Integer> currentRule, Integer newValue, String string) {
|
||||
@Override public Integer validate(CommandSourceStack source, ParsedRule<Integer> currentRule, Integer newValue, String string) {
|
||||
return (newValue>0 && newValue <= 20000000) ? newValue : null;
|
||||
}
|
||||
@Override
|
||||
@@ -676,7 +676,7 @@ public class CarpetSettings
|
||||
|
||||
private static class ViewDistanceValidator extends Validator<Integer>
|
||||
{
|
||||
@Override public Integer validate(ServerCommandSource source, ParsedRule<Integer> currentRule, Integer newValue, String string)
|
||||
@Override public Integer validate(CommandSourceStack source, ParsedRule<Integer> currentRule, Integer newValue, String string)
|
||||
{
|
||||
if (currentRule.get().equals(newValue) || source == null)
|
||||
{
|
||||
@@ -689,11 +689,11 @@ public class CarpetSettings
|
||||
}
|
||||
MinecraftServer server = source.getServer();
|
||||
|
||||
if (server.isDedicated())
|
||||
if (server.isDedicatedServer())
|
||||
{
|
||||
int vd = (newValue >= 2)?newValue:((DedicatedServer) server).getProperties().viewDistance;
|
||||
if (vd != server.getPlayerManager().getViewDistance())
|
||||
server.getPlayerManager().setViewDistance(vd);
|
||||
int vd = (newValue >= 2)?newValue:((ServerInterface) server).getProperties().viewDistance;
|
||||
if (vd != server.getPlayerList().getViewDistance())
|
||||
server.getPlayerList().setViewDistance(vd);
|
||||
return newValue;
|
||||
}
|
||||
else
|
||||
@@ -718,17 +718,17 @@ public class CarpetSettings
|
||||
public static class ChangeSpawnChunksValidator extends Validator<Integer> {
|
||||
public static void changeSpawnSize(int size)
|
||||
{
|
||||
ServerWorld overworld = CarpetServer.minecraft_server.getWorld(World.OVERWORLD); // OW
|
||||
ServerLevel overworld = CarpetServer.minecraft_server.getLevel(Level.OVERWORLD); // OW
|
||||
if (overworld != null) {
|
||||
ChunkPos centerChunk = new ChunkPos(new BlockPos(
|
||||
overworld.getLevelProperties().getSpawnX(),
|
||||
overworld.getLevelProperties().getSpawnY(),
|
||||
overworld.getLevelProperties().getSpawnZ()
|
||||
overworld.getLevelData().getXSpawn(),
|
||||
overworld.getLevelData().getYSpawn(),
|
||||
overworld.getLevelData().getZSpawn()
|
||||
));
|
||||
SpawnChunks.changeSpawnChunks(overworld.getChunkManager(), centerChunk, size);
|
||||
SpawnChunks.changeSpawnChunks(overworld.getChunkSource(), centerChunk, size);
|
||||
}
|
||||
}
|
||||
@Override public Integer validate(ServerCommandSource source, ParsedRule<Integer> currentRule, Integer newValue, String string) {
|
||||
@Override public Integer validate(CommandSourceStack source, ParsedRule<Integer> currentRule, Integer newValue, String string) {
|
||||
if (source == null) return newValue;
|
||||
if (newValue < 0 || newValue > 32)
|
||||
{
|
||||
@@ -741,7 +741,7 @@ public class CarpetSettings
|
||||
return newValue;
|
||||
}
|
||||
if (CarpetServer.minecraft_server == null) return newValue;
|
||||
ServerWorld currentOverworld = CarpetServer.minecraft_server.getWorld(World.OVERWORLD); // OW
|
||||
ServerLevel currentOverworld = CarpetServer.minecraft_server.getLevel(Level.OVERWORLD); // OW
|
||||
if (currentOverworld != null)
|
||||
{
|
||||
changeSpawnSize(newValue);
|
||||
@@ -762,15 +762,15 @@ public class CarpetSettings
|
||||
public static class LightBatchValidator extends Validator<Integer> {
|
||||
public static void applyLightBatchSizes()
|
||||
{
|
||||
Iterator<ServerWorld> iterator = CarpetServer.minecraft_server.getWorlds().iterator();
|
||||
Iterator<ServerLevel> iterator = CarpetServer.minecraft_server.getAllLevels().iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
ServerWorld serverWorld = iterator.next();
|
||||
serverWorld.getChunkManager().getLightingProvider().setTaskBatchSize(lightEngineMaxBatchSize);
|
||||
ServerLevel serverWorld = iterator.next();
|
||||
serverWorld.getChunkSource().getLightEngine().setTaskPerBatch(lightEngineMaxBatchSize);
|
||||
}
|
||||
}
|
||||
@Override public Integer validate(ServerCommandSource source, ParsedRule<Integer> currentRule, Integer newValue, String string) {
|
||||
@Override public Integer validate(CommandSourceStack source, ParsedRule<Integer> currentRule, Integer newValue, String string) {
|
||||
if (source == null) return newValue;
|
||||
if (newValue < 0)
|
||||
{
|
||||
@@ -893,7 +893,7 @@ public class CarpetSettings
|
||||
public static boolean isCreativeFlying(Entity entity)
|
||||
{
|
||||
// #todo replace after merger to 1.17
|
||||
return CarpetSettings.creativeNoClip && entity instanceof PlayerEntity && (((PlayerEntity) entity).isCreative()) && ((PlayerEntity) entity).getAbilities().flying;
|
||||
return CarpetSettings.creativeNoClip && entity instanceof Player && (((Player) entity).isCreative()) && ((Player) entity).getAbilities().flying;
|
||||
}
|
||||
|
||||
|
||||
@@ -938,7 +938,7 @@ public class CarpetSettings
|
||||
|
||||
public static class StructureBlockLimitValidator extends Validator<Integer> {
|
||||
|
||||
@Override public Integer validate(ServerCommandSource source, ParsedRule<Integer> currentRule, Integer newValue, String string) {
|
||||
@Override public Integer validate(CommandSourceStack source, ParsedRule<Integer> currentRule, Integer newValue, String string) {
|
||||
return (newValue >= vanillaStructureBlockLimit) ? newValue : null;
|
||||
}
|
||||
|
||||
@@ -965,8 +965,8 @@ public class CarpetSettings
|
||||
public static class StructureBlockIgnoredValidator extends Validator<String> {
|
||||
|
||||
@Override
|
||||
public String validate(ServerCommandSource source, ParsedRule<String> currentRule, String newValue, String string) {
|
||||
Optional<Block> ignoredBlock = Registry.BLOCK.getOrEmpty(Identifier.tryParse(newValue));
|
||||
public String validate(CommandSourceStack source, ParsedRule<String> currentRule, String newValue, String string) {
|
||||
Optional<Block> ignoredBlock = Registry.BLOCK.getOptional(ResourceLocation.tryParse(newValue));
|
||||
if (!ignoredBlock.isPresent()) {
|
||||
Messenger.m(source, "r Unknown block '" + newValue + "'.");
|
||||
return null;
|
||||
@@ -1027,7 +1027,7 @@ public class CarpetSettings
|
||||
|
||||
private static class updateSuppressionBlockModes extends Validator<String> {
|
||||
@Override
|
||||
public String validate(ServerCommandSource source, ParsedRule<String> currentRule, String newValue, String string) {
|
||||
public String validate(CommandSourceStack source, ParsedRule<String> currentRule, String newValue, String string) {
|
||||
if (!currentRule.get().equals(newValue)) {
|
||||
if (newValue.equalsIgnoreCase("false")) {
|
||||
updateSuppressionBlockSetting = -1;
|
||||
|
||||
Reference in new issue
Block a user