23w03a
This commit is contained in:
1 parent
2b95a878ad
commit
c7d506675e
19 files changed
+107
-43
No files matched your search
@@ -55,7 +55,6 @@ public class CarpetSettings
|
||||
public static final Logger LOG = LoggerFactory.getLogger("carpet");
|
||||
public static final ThreadLocal<Boolean> skipGenerationChecks = ThreadLocal.withInitial(() -> false);
|
||||
public static final ThreadLocal<Boolean> impendingFillSkipUpdates = ThreadLocal.withInitial(() -> false);
|
||||
public static final int VANILLA_FILL_LIMIT = 32768;
|
||||
public static int runPermissionLevel = 2;
|
||||
public static boolean doChainStone = false;
|
||||
public static boolean chainStoneStickToAll = false;
|
||||
@@ -632,14 +631,14 @@ public class CarpetSettings
|
||||
public String description() { return "You must choose a value from 1 to 20M";}
|
||||
}
|
||||
@Rule(
|
||||
desc = "Customizable fill/fillbiome/clone volume limit",
|
||||
desc = "[Deprecated] Customizable fill/fillbiome/clone volume limit",
|
||||
extra = "Use vanilla gamerule instead. This setting will be removed in 1.20.0",
|
||||
options = {"32768", "250000", "1000000"},
|
||||
category = CREATIVE,
|
||||
strict = false,
|
||||
validate = FillLimitLimits.class
|
||||
)
|
||||
public static int fillLimit = VANILLA_FILL_LIMIT;
|
||||
|
||||
public static int fillLimit = 32768;
|
||||
|
||||
@Rule(
|
||||
desc = "Customizable forceload chunk limit",
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.mojang.brigadier.suggestion.Suggestions;
|
||||
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
|
||||
import net.minecraft.commands.CommandBuildContext;
|
||||
import net.minecraft.world.level.GameRules;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -516,7 +517,7 @@ public class ScriptCommand
|
||||
BoundingBox area = BoundingBox.fromCorners(a, b);
|
||||
CarpetExpression cexpr = new CarpetExpression(host.main, expr, source, origin);
|
||||
int int_1 = area.getXSpan() * area.getYSpan() * area.getZSpan(); // X Y Z
|
||||
if (int_1 > CarpetSettings.fillLimit)
|
||||
if (int_1 > Math.max(source.getServer().getGameRules().getInt(GameRules.RULE_COMMAND_MODIFICATION_BLOCK_LIMIT), CarpetSettings.fillLimit))
|
||||
{
|
||||
Messenger.m(source, "r too many blocks to evaluate: " + int_1);
|
||||
return 1;
|
||||
@@ -565,7 +566,7 @@ public class ScriptCommand
|
||||
BoundingBox area = BoundingBox.fromCorners(a, b);
|
||||
CarpetExpression cexpr = new CarpetExpression(host.main, expr, source, origin);
|
||||
int int_1 = area.getXSpan() * area.getYSpan() * area.getZSpan();
|
||||
if (int_1 > CarpetSettings.fillLimit)
|
||||
if (int_1 > Math.max(source.getServer().getGameRules().getInt(GameRules.RULE_COMMAND_MODIFICATION_BLOCK_LIMIT), CarpetSettings.fillLimit))
|
||||
{
|
||||
Messenger.m(source, "r too many blocks to evaluate: "+ int_1);
|
||||
return 1;
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package carpet.fakes;
|
||||
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
|
||||
public interface BiomeInterface {
|
||||
Biome.ClimateSettings getClimateSettings();
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package carpet.fakes;
|
||||
|
||||
import net.minecraft.network.Connection;
|
||||
|
||||
public interface ServerGamePacketListenerImplInterface {
|
||||
Connection getConnection();
|
||||
}
|
||||
@@ -11,7 +11,6 @@ import net.minecraft.network.protocol.game.ClientboundTabListPacket;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.level.Level;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -20,6 +19,7 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.OptionalDouble;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@@ -116,7 +116,12 @@ public class HUDController
|
||||
}
|
||||
private static Component [] send_tps_display(MinecraftServer server)
|
||||
{
|
||||
double MSPT = Mth.average(server.tickTimes) * 1.0E-6D;
|
||||
final OptionalDouble averageTPS = Arrays.stream(server.tickTimes).average();
|
||||
if (averageTPS.isEmpty())
|
||||
{
|
||||
return new Component[]{Component.literal("No TPS data available")};
|
||||
}
|
||||
double MSPT = Arrays.stream(server.tickTimes).average().getAsDouble() * 1.0E-6D;
|
||||
double TPS = 1000.0D / Math.max((TickSpeed.time_warp_start_time != 0)?0.0:TickSpeed.mspt, MSPT);
|
||||
if (TickSpeed.isPaused()) {
|
||||
TPS = 0;
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.fakes.BiomeInterface;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(Biome.class)
|
||||
public class Biome_scarpetMixin implements BiomeInterface {
|
||||
@Shadow
|
||||
private Biome.ClimateSettings climateSettings;
|
||||
|
||||
@Override
|
||||
public Biome.ClimateSettings getClimateSettings() {
|
||||
return climateSettings;
|
||||
}
|
||||
}
|
||||
@@ -4,20 +4,24 @@ import carpet.CarpetSettings;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.commands.CloneCommands;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.GameRules;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Constant;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
|
||||
@Mixin(CloneCommands.class)
|
||||
public abstract class CloneCommands_fillUpdatesMixin
|
||||
{
|
||||
@ModifyConstant(method = "clone", constant = @Constant(intValue = CarpetSettings.VANILLA_FILL_LIMIT))
|
||||
private static int fillLimit(int original) {
|
||||
return CarpetSettings.fillLimit;
|
||||
@Redirect(method = "clone", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/level/GameRules;getInt(Lnet/minecraft/world/level/GameRules$Key;)I"
|
||||
))
|
||||
private static int redirectCloneGameRuleInt(GameRules instance, GameRules.Key<GameRules.IntegerValue> key)
|
||||
{
|
||||
int vanilla = instance.getInt(key);
|
||||
return Math.max(vanilla, CarpetSettings.fillLimit);
|
||||
}
|
||||
|
||||
@Redirect(method = "clone", at = @At(
|
||||
|
||||
@@ -2,16 +2,21 @@ package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.server.commands.FillBiomeCommand;
|
||||
import net.minecraft.world.level.GameRules;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.Constant;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(FillBiomeCommand.class)
|
||||
public class FillBiomeCommandMixin
|
||||
{
|
||||
@ModifyConstant(method = "fill", constant = @Constant(intValue = CarpetSettings.VANILLA_FILL_LIMIT))
|
||||
private static int fillLimit(int original)
|
||||
@Redirect(method = "fill", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/level/GameRules;getInt(Lnet/minecraft/world/level/GameRules$Key;)I"
|
||||
))
|
||||
private static int redirectCloneGameRuleInt(GameRules instance, GameRules.Key<GameRules.IntegerValue> key)
|
||||
{
|
||||
return CarpetSettings.fillLimit;
|
||||
int vanilla = instance.getInt(key);
|
||||
return Math.max(vanilla, CarpetSettings.fillLimit);
|
||||
}
|
||||
}
|
||||
@@ -4,20 +4,24 @@ import carpet.CarpetSettings;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.commands.FillCommand;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.GameRules;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Constant;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(FillCommand.class)
|
||||
public abstract class FillCommandMixin
|
||||
{
|
||||
@ModifyConstant(method = "fillBlocks", constant = @Constant(intValue = CarpetSettings.VANILLA_FILL_LIMIT))
|
||||
private static int fillLimit(int original)
|
||||
|
||||
@Redirect(method = "fillBlocks", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/level/GameRules;getInt(Lnet/minecraft/world/level/GameRules$Key;)I"
|
||||
))
|
||||
private static int redirectCloneGameRuleInt(GameRules instance, GameRules.Key<GameRules.IntegerValue> key)
|
||||
{
|
||||
return CarpetSettings.fillLimit;
|
||||
int vanilla = instance.getInt(key);
|
||||
return Math.max(vanilla, CarpetSettings.fillLimit);
|
||||
}
|
||||
|
||||
@Redirect(method = "fillBlocks", at = @At(
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetServer;
|
||||
import carpet.fakes.ServerGamePacketListenerImplInterface;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
||||
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;
|
||||
@@ -13,13 +16,20 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import static carpet.script.CarpetEventServer.Event.PLAYER_DISCONNECTS;
|
||||
|
||||
@Mixin(ServerGamePacketListenerImpl.class)
|
||||
public class ServerGamePacketListenerImpl_coreMixin {
|
||||
public class ServerGamePacketListenerImpl_coreMixin implements ServerGamePacketListenerImplInterface {
|
||||
@Shadow
|
||||
public ServerPlayer player;
|
||||
|
||||
@Shadow @Final private Connection connection;
|
||||
|
||||
@Inject(method = "onDisconnect", at = @At("HEAD"))
|
||||
private void onPlayerDisconnect(Component reason, CallbackInfo ci) {
|
||||
CarpetServer.onPlayerLoggedOut(this.player);
|
||||
if (PLAYER_DISCONNECTS.isNeeded()) PLAYER_DISCONNECTS.onPlayerMessage(player, reason.getContents().toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Connection getConnection() {
|
||||
return connection;
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import carpet.CarpetServer;
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.api.settings.CarpetRule;
|
||||
import carpet.api.settings.RuleHelper;
|
||||
import carpet.fakes.ServerGamePacketListenerImplInterface;
|
||||
import carpet.helpers.TickSpeed;
|
||||
import carpet.script.utils.SnoopyCommandSource;
|
||||
import carpet.api.settings.SettingsManager;
|
||||
@@ -51,7 +52,7 @@ public class ServerNetworkHandler
|
||||
|
||||
public static void onPlayerJoin(ServerPlayer playerEntity)
|
||||
{
|
||||
if (!playerEntity.connection.connection.isMemoryConnection())
|
||||
if (!((ServerGamePacketListenerImplInterface)playerEntity.connection).getConnection().isMemoryConnection())
|
||||
{
|
||||
playerEntity.connection.send(new ClientboundCustomPayloadPacket(
|
||||
CarpetClient.CARPET_CHANNEL,
|
||||
@@ -218,7 +219,7 @@ public class ServerNetworkHandler
|
||||
public static void onPlayerLoggedOut(ServerPlayer player)
|
||||
{
|
||||
validCarpetPlayers.remove(player);
|
||||
if (!player.connection.connection.isMemoryConnection())
|
||||
if (!((ServerGamePacketListenerImplInterface)player.connection).getConnection().isMemoryConnection())
|
||||
remoteCarpetPlayers.remove(player);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,6 @@ import carpet.script.value.Value;
|
||||
import carpet.script.value.ValueConversions;
|
||||
import carpet.utils.Messenger;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.mojang.bridge.game.PackType;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@@ -66,6 +65,7 @@ import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.packs.PackType;
|
||||
import net.minecraft.server.packs.repository.Pack;
|
||||
import net.minecraft.server.packs.repository.PackRepository;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
@@ -1056,7 +1056,7 @@ public class Auxiliary {
|
||||
Path zipRoot = zipfs.getPath("/");
|
||||
zipValueToJson(zipRoot.resolve("pack.mcmeta"), MapValue.wrap(
|
||||
Map.of(StringValue.of("pack"), MapValue.wrap(Map.of(
|
||||
StringValue.of("pack_format"), new NumericValue(SharedConstants.getCurrentVersion().getPackVersion(PackType.DATA)),
|
||||
StringValue.of("pack_format"), new NumericValue(SharedConstants.getCurrentVersion().getPackVersion(PackType.SERVER_DATA)),
|
||||
StringValue.of("description"), StringValue.of(name),
|
||||
StringValue.of("source"), StringValue.of("scarpet")
|
||||
)))
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
package carpet.script.utils;
|
||||
|
||||
import carpet.fakes.BiomeInterface;
|
||||
import carpet.script.value.ListValue;
|
||||
import carpet.script.value.NumericValue;
|
||||
import carpet.script.value.StringValue;
|
||||
import carpet.script.value.Value;
|
||||
import carpet.script.value.ValueConversions;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
@@ -30,8 +33,8 @@ public class BiomeInfo
|
||||
put("sky_color", (w, b) -> ValueConversions.ofRGB(b.getSpecialEffects().getSkyColor()));
|
||||
put("water_color", (w, b) -> ValueConversions.ofRGB(b.getSpecialEffects().getWaterColor()));
|
||||
put("water_fog_color", (w, b) -> ValueConversions.ofRGB(b.getSpecialEffects().getWaterFogColor()));
|
||||
put("humidity", (w, b) -> NumericValue.of(b.getDownfall()));
|
||||
put("precipitation", (w, b) -> StringValue.of(b.getPrecipitation().getName()));
|
||||
put("humidity", (w, b) -> NumericValue.of(((BiomeInterface) (Object) b).getClimateSettings().downfall()));
|
||||
put("precipitation", (w, b) -> StringValue.of(b.getPrecipitationAt(new BlockPos(0, w.getSeaLevel(), 0)).name().toLowerCase(Locale.ROOT)));
|
||||
//put("depth", (w, b) -> NumericValue.of(b.getDepth()));
|
||||
//put("scale", (w, b) -> NumericValue.of(b.getScale()));
|
||||
put("features", (w, b) -> {
|
||||
|
||||
@@ -87,7 +87,6 @@ public class ShapesRenderer
|
||||
if ((shapes.get(dimensionType) == null || shapes.get(dimensionType).isEmpty()) &&
|
||||
(labels.get(dimensionType) == null || labels.get(dimensionType).isEmpty())) return;
|
||||
long currentTime = client.level.getGameTime();
|
||||
RenderSystem.disableTexture();
|
||||
RenderSystem.enableDepthTest();
|
||||
RenderSystem.setShader(GameRenderer::getPositionColorShader);
|
||||
RenderSystem.depthFunc(515);
|
||||
@@ -148,7 +147,6 @@ public class ShapesRenderer
|
||||
RenderSystem.depthMask(true);
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.defaultBlendFunc();
|
||||
RenderSystem.enableTexture();
|
||||
CarpetProfiler.end_current_section(token);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,11 +15,11 @@ import carpet.script.value.StringValue;
|
||||
import carpet.script.value.Value;
|
||||
import carpet.script.value.ValueConversions;
|
||||
import carpet.api.settings.SettingsManager;
|
||||
import com.mojang.bridge.game.PackType;
|
||||
import com.sun.management.OperatingSystemMXBean;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.fabricmc.loader.api.ModContainer;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.server.packs.PackType;
|
||||
import net.minecraft.world.level.GameRules;
|
||||
import net.minecraft.world.level.border.WorldBorder;
|
||||
import net.minecraft.world.level.storage.LevelData;
|
||||
@@ -99,8 +99,8 @@ public class SystemInfo {
|
||||
return NumericValue.of((vers.length > 2)?Integer.parseInt(vers[2]):0);
|
||||
});
|
||||
put("game_stable", c -> BooleanValue.of(SharedConstants.getCurrentVersion().isStable()));
|
||||
put("game_data_version", c->NumericValue.of(SharedConstants.getCurrentVersion().getWorldVersion()));
|
||||
put("game_pack_version", c->NumericValue.of(SharedConstants.getCurrentVersion().getPackVersion(PackType.DATA)));
|
||||
put("game_data_version", c->NumericValue.of(SharedConstants.getCurrentVersion().getDataVersion().getVersion()));
|
||||
put("game_pack_version", c->NumericValue.of(SharedConstants.getCurrentVersion().getPackVersion(PackType.SERVER_DATA)));
|
||||
|
||||
put("server_ip", c -> StringValue.of(c.server().getLocalIp()));
|
||||
put("server_whitelisted", c -> BooleanValue.of(c.server().isEnforceWhitelist()));
|
||||
|
||||
@@ -55,6 +55,7 @@ import net.minecraft.world.entity.MobCategory;
|
||||
import net.minecraft.world.entity.MobType;
|
||||
import net.minecraft.world.entity.PathfinderMob;
|
||||
import net.minecraft.world.entity.Pose;
|
||||
import net.minecraft.world.entity.RelativeMovement;
|
||||
import net.minecraft.world.entity.ai.Brain;
|
||||
import net.minecraft.world.entity.ai.attributes.Attribute;
|
||||
import net.minecraft.world.entity.ai.attributes.AttributeMap;
|
||||
@@ -989,9 +990,9 @@ public class EntityValue extends Value
|
||||
if (e instanceof ServerPlayer)
|
||||
{
|
||||
// this forces position but doesn't angles for some reason. Need both in the API in the future.
|
||||
EnumSet<ClientboundPlayerPositionPacket.RelativeArgument> set = EnumSet.noneOf(ClientboundPlayerPositionPacket.RelativeArgument.class);
|
||||
set.add(ClientboundPlayerPositionPacket.RelativeArgument.X_ROT);
|
||||
set.add(ClientboundPlayerPositionPacket.RelativeArgument.Y_ROT);
|
||||
EnumSet<RelativeMovement> set = EnumSet.noneOf(RelativeMovement.class);
|
||||
set.add(RelativeMovement.X_ROT);
|
||||
set.add(RelativeMovement.Y_ROT);
|
||||
((ServerPlayer)e).connection.teleport(x, y, z, yaw, pitch, set );
|
||||
}
|
||||
else
|
||||
|
||||
@@ -5,5 +5,6 @@ accessible class net/minecraft/server/level/ThreadedLevelLightEngine$TaskType
|
||||
accessible class net/minecraft/world/item/crafting/Ingredient$Value
|
||||
accessible class net/minecraft/world/level/lighting/BlockLightSectionStorage$BlockDataLayerStorageMap
|
||||
accessible class net/minecraft/server/MinecraftServer$ReloadableResources
|
||||
accessible class net/minecraft/world/level/biome/Biome$ClimateSettings
|
||||
|
||||
accessible field net/minecraft/world/level/block/state/BlockBehaviour UPDATE_SHAPE_ORDER [Lnet/minecraft/core/Direction;
|
||||
@@ -165,6 +165,7 @@
|
||||
"HorseBaseEntity_scarpetMixin",
|
||||
"NoiseSampler_scarpetMixin",
|
||||
"QuantizedSpaghettiRarityMixin_scarpetMixin",
|
||||
"Biome_scarpetMixin",
|
||||
|
||||
"BlockEntity_movableBEMixin",
|
||||
"PistonBaseBlock_movableBEMixin",
|
||||
|
||||
Reference in new issue
Block a user