This commit is contained in:
gnembon committed 2025-07-31 01:57:08 +02:00
1 parent 49840619f5
commit 134d839625
18 files changed
+56 -44

No files matched your search

+2 -1
View File
@@ -778,7 +778,8 @@ system calls. In all circumstances, these are only provided as read-only.
* `game_major_target` - major release target. For 1.12.2, that would be 12
* `game_minor_release` - minor release target. For 1.12.2, that would be 2
* `game_protocol` - protocol version number
* `game_pack_version` - datapack version number
* `game_pack_version` - datapack version number as a version string
* `game_pack_minor_version` - datapack format minor version number
* `game_data_version` - data version of the game. Returns an integer, so it can be compared.
* `game_stable` - indicating if its a production release or a snapshot
+1 -1
View File
@@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check https://fabricmc.net/develop/
minecraft_version=1.21.8
minecraft_version=25w31a
loader_version=0.16.14
jsr305_version=3.0.2
fabric_version=0.119.5+1.21.5
@@ -29,6 +29,7 @@ import net.minecraft.core.UUIDUtil;
import net.minecraft.resources.ResourceKey;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.players.NameAndId;
import net.minecraft.server.players.PlayerList;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.GameType;
@@ -164,7 +165,7 @@ public class PlayerCommand
return false;
}
if (!source.getServer().getPlayerList().isOp(sender.getGameProfile()))
if (!source.getServer().getPlayerList().isOp(sender.nameAndId()))
{
if (sender != player && !(player instanceof EntityPlayerMPFake))
{
@@ -200,7 +201,7 @@ public class PlayerCommand
Messenger.m(context.getSource(), "r Player ", "rb " + playerName, "r is already logged on");
return true;
}
GameProfile profile = server.getProfileCache().get(playerName).orElse(null);
NameAndId profile = server.nameToIdCache().get(playerName).orElse(null);
if (profile == null)
{
if (!CarpetSettings.allowSpawningOfflinePlayers)
@@ -209,7 +210,7 @@ public class PlayerCommand
"Banned players can only be summoned in Singleplayer and in servers in off-line mode.");
return true;
} else {
profile = new GameProfile(UUIDUtil.createOfflinePlayerUUID(playerName), playerName);
profile = new NameAndId(UUIDUtil.createOfflinePlayerUUID(playerName), playerName);
}
}
if (manager.getBans().isBanned(profile))
@@ -337,7 +338,7 @@ public class PlayerCommand
Messenger.m(context.getSource(), "r Cannot shadow fake players");
return 0;
}
if (player.getServer().isSingleplayerOwner(player.getGameProfile())) {
if (player.getServer().isSingleplayerOwner(player.nameAndId())) {
Messenger.m(context.getSource(), "r Cannot shadow single-player server owner");
return 0;
}
@@ -201,7 +201,7 @@ public class EntityPlayerActionPack
if (closest instanceof AbstractHorse && onlyRideables)
((AbstractHorse) closest).mobInteract(player, InteractionHand.MAIN_HAND);
else
player.startRiding(closest,true);
player.startRiding(closest,true, true);
return this;
}
public EntityPlayerActionPack dismount()
@@ -27,7 +27,7 @@ import net.minecraft.server.level.ChunkResult;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ThreadedLevelLightEngine;
import net.minecraft.server.level.TicketType;
import net.minecraft.server.level.progress.ChunkProgressListener;
import net.minecraft.util.thread.BlockableEventLoop;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
@@ -83,9 +83,9 @@ public abstract class ChunkMap_scarpetChunkCreationMixin implements ThreadedAnvi
@Final
private BlockableEventLoop<Runnable> mainThreadExecutor;
@Shadow
@Final
private ChunkProgressListener progressListener;
//@Shadow
//@Final
//private ChunkProgressListener progressListener;
@Shadow
@Final
@@ -2,13 +2,14 @@ package carpet.mixins;
import carpet.CarpetSettings;
import net.minecraft.client.renderer.DimensionSpecialEffects;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.renderer.LevelRenderer;
//import net.minecraft.world.dimension.Dimension;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(value = LevelRenderer.class, priority = 69420)
@Mixin(value = GameRenderer.class, priority = 69420)
public class LevelRenderer_fogOffMixin
{
@Redirect(method = "renderLevel", require = 0, expect = 0, at = @At(
@@ -7,12 +7,13 @@ import com.mojang.blaze3d.framegraph.FrameGraphBuilder;
import com.mojang.blaze3d.framegraph.FramePass;
import net.minecraft.client.Camera;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.LevelRenderState;
import net.minecraft.client.renderer.LevelRenderer;
import net.minecraft.client.renderer.LevelTargetBundle;
import net.minecraft.client.renderer.LightTexture;
import net.minecraft.client.renderer.RenderBuffers;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher;
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
import net.minecraft.client.renderer.feature.FeatureRenderDispatcher;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@@ -26,7 +27,7 @@ public class LevelRenderer_scarpetRenderMixin
@Shadow @Final private LevelTargetBundle targets;
@Inject(method = "<init>", at = @At("RETURN"))
private void addRenderers(Minecraft minecraft, EntityRenderDispatcher entityRenderDispatcher, BlockEntityRenderDispatcher blockEntityRenderDispatcher, RenderBuffers renderBuffers, CallbackInfo ci)
private void addRenderers(Minecraft minecraft, EntityRenderDispatcher entityRenderDispatcher, BlockEntityRenderDispatcher blockEntityRenderDispatcher, RenderBuffers renderBuffers, LevelRenderState levelRenderState, FeatureRenderDispatcher featureRenderDispatcher, CallbackInfo ci)
{
CarpetClient.shapes = new ShapesRenderer(minecraft);
}
@@ -24,7 +24,7 @@ public abstract class PistonHeadRenderer_movableBEMixin implements BlockEntityRe
@Inject(method = "<init>", at = @At("TAIL"))
private void onInitCM(BlockEntityRendererProvider.Context arguments, CallbackInfo ci)
{
dispatcher = arguments.getBlockEntityRenderDispatcher();
dispatcher = arguments.blockEntityRenderDispatcher();
}
@Inject(method = "render", at = @At(value = "INVOKE",
@@ -18,6 +18,7 @@ import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import carpet.patches.NetHandlerPlayServerFake;
import carpet.patches.EntityPlayerMPFake;
@@ -31,8 +32,9 @@ public abstract class PlayerList_fakePlayersMixin
@Final
private MinecraftServer server;
@Inject(method = "load", at = @At(value = "RETURN", shift = At.Shift.BEFORE))
private void fixStartingPos(ServerPlayer serverPlayer, ProblemReporter problemReporter, CallbackInfoReturnable<Optional<ValueInput>> cir)
// may need to be invoked in the configuration phase on prepareSpawn Task
@Inject(method = "placeNewPlayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerPlayer;level()Lnet/minecraft/server/level/ServerLevel;"))
private void fixStartingPos(Connection connection, ServerPlayer serverPlayer, CommonListenerCookie commonListenerCookie, CallbackInfo ci)
{
if (serverPlayer instanceof EntityPlayerMPFake)
{
@@ -2,8 +2,10 @@ package carpet.patches;
import carpet.CarpetSettings;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.PropertyMap;
import net.minecraft.core.BlockPos;
import net.minecraft.core.UUIDUtil;
import net.minecraft.core.component.DataComponents;
import net.minecraft.network.DisconnectionDetails;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.contents.TranslatableContents;
@@ -19,7 +21,8 @@ import net.minecraft.server.level.ClientInformation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.network.CommonListenerCookie;
import net.minecraft.server.players.GameProfileCache;
import net.minecraft.server.players.CachedUserNameToIdResolver;
import net.minecraft.server.players.NameAndId;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EquipmentSlot;
@@ -27,6 +30,7 @@ import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.food.FoodData;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.component.ResolvableProfile;
import net.minecraft.world.level.GameType;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.SkullBlockEntity;
@@ -54,13 +58,14 @@ public class EntityPlayerMPFake extends ServerPlayer
{
//prolly half of that crap is not necessary, but it works
ServerLevel worldIn = server.getLevel(dimensionId);
GameProfileCache.setUsesAuthentication(false);
server.nameToIdCache().resolveOfflineUsers(false);
GameProfile gameprofile;
try {
gameprofile = server.getProfileCache().get(username).orElse(null); //findByName .orElse(null)
NameAndId res = server.nameToIdCache().get(username).orElseThrow(); //findByName .orElse(null)
gameprofile = new GameProfile(res.id(), res.name());
}
finally {
GameProfileCache.setUsesAuthentication(server.isDedicatedServer() && server.usesAuthentication());
server.nameToIdCache().resolveOfflineUsers(server.isDedicatedServer() && server.usesAuthentication());
}
if (gameprofile == null)
{
@@ -71,7 +76,7 @@ public class EntityPlayerMPFake extends ServerPlayer
gameprofile = new GameProfile(UUIDUtil.createOfflinePlayerUUID(username), username);
}
}
GameProfile finalGP = gameprofile;
//GameProfile finalGP = gameprofile;
// We need to mark this player as spawning so that we do not
// try to spawn another player with the name while the profile
@@ -87,11 +92,8 @@ public class EntityPlayerMPFake extends ServerPlayer
return;
}
GameProfile current = finalGP;
if (p.isPresent())
{
current = p.get();
}
GameProfile current = p.gameProfile();
EntityPlayerMPFake instance = new EntityPlayerMPFake(server, worldIn, current, ClientInformation.createDefault(), false);
instance.fixStartingPosition = () -> instance.snapTo(pos.x, pos.y, pos.z, (float) yaw, (float) pitch);
server.getPlayerList().placeNewPlayer(new FakeClientConnection(PacketFlow.SERVERBOUND), instance, new CommonListenerCookie(current, 0, instance.clientInformation(), false));
@@ -109,8 +111,9 @@ public class EntityPlayerMPFake extends ServerPlayer
return true;
}
private static CompletableFuture<Optional<GameProfile>> fetchGameProfile(final String name) {
return SkullBlockEntity.fetchGameProfile(name);
private static CompletableFuture<ResolvableProfile> fetchGameProfile(final String name) {
final ResolvableProfile resolvableProfile = new ResolvableProfile(Optional.of(name), Optional.empty(), new PropertyMap());
return resolvableProfile.resolve();
}
public static EntityPlayerMPFake createShadow(MinecraftServer server, ServerPlayer player)
@@ -1195,7 +1195,8 @@ 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().packVersion(PackType.SERVER_DATA)),
StringValue.of("min_format"), new NumericValue(SharedConstants.getCurrentVersion().packVersion(PackType.SERVER_DATA).major()),
StringValue.of("max_format"), new NumericValue(SharedConstants.getCurrentVersion().packVersion(PackType.SERVER_DATA).major()),
StringValue.of("description"), StringValue.of(name),
StringValue.of("source"), StringValue.of("scarpet")
)))
@@ -1744,7 +1744,7 @@ public class WorldAccess
case "erosion" -> router.erosion();
case "depth" -> router.depth();
case "ridges" -> router.ridges();
case "initial_density_without_jaggedness" -> router.initialDensityWithoutJaggedness();
case "preliminary_surface_level" -> router.preliminarySurfaceLevel();
case "final_density" -> router.finalDensity();
case "vein_toggle" -> router.veinToggle();
case "vein_ridged" -> router.veinRidged();
@@ -1776,7 +1776,7 @@ public class WorldAccess
case "erosion" -> router.erosion();
case "depth" -> router.depth();
case "ridges" -> router.ridges();
case "initial_density_without_jaggedness" -> router.initialDensityWithoutJaggedness();
case "preliminary_surface_level" -> router.preliminarySurfaceLevel();
case "final_density" -> router.finalDensity();
case "vein_toggle" -> router.veinToggle();
case "vein_ridged" -> router.veinRidged();
@@ -102,6 +102,7 @@ import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.commands.BossBarCommands;
import net.minecraft.server.commands.LootCommand;
import net.minecraft.server.players.NameAndId;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.phys.Vec2;
@@ -718,10 +719,10 @@ public abstract class CommandArgument
@Override
protected Value getValueFromContext(CommandContext<CommandSourceStack> context, String param) throws CommandSyntaxException
{
Collection<GameProfile> profiles = GameProfileArgument.getGameProfiles(context, param);
Collection<NameAndId> profiles = GameProfileArgument.getGameProfiles(context, param);
if (!single)
{
return ListValue.wrap(profiles.stream().map(p -> StringValue.of(p.getName())));
return ListValue.wrap(profiles.stream().map(p -> StringValue.of(p.name())));
}
int size = profiles.size();
if (size == 0)
@@ -730,7 +731,7 @@ public abstract class CommandArgument
}
if (size == 1)
{
return StringValue.of(profiles.iterator().next().getName());
return StringValue.of(profiles.iterator().next().name());
}
throw new SimpleCommandExceptionType(Component.literal("Multiple game profiles returned while only one was requested" + " for custom type " + suffix)).create();
}
@@ -25,6 +25,7 @@ import java.util.function.BiFunction;
import net.minecraft.client.Camera;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.components.debug.DebugScreenEntries;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.renderer.ItemBlockRenderTypes;
import net.minecraft.client.renderer.LightTexture;
@@ -143,7 +144,7 @@ public class ShapesRenderer
double cameraX = camera.getPosition().x;
double cameraY = camera.getPosition().y;
double cameraZ = camera.getPosition().z;
boolean entityBoxes = client.getEntityRenderDispatcher().shouldRenderHitBoxes();
boolean entityBoxes = client.debugEntries.isCurrentlyEnabled(DebugScreenEntries.ENTITY_HITBOXES);
if (!shapes.isEmpty())
{
@@ -70,12 +70,12 @@ public class SnoopyCommandSource extends CommandSourceStack
{
super(player.commandSource(), player.position(), player.getRotationVector(),
player.level() instanceof final ServerLevel serverLevel ? serverLevel : null,
player.getServer().getProfilePermissions(player.getGameProfile()), player.getName().getString(), player.getDisplayName(),
player.getServer().getProfilePermissions(player.nameAndId()), player.getName().getString(), player.getDisplayName(),
player.level().getServer(), player);
this.output = player.commandSource();
this.position = player.position();
this.world = player.level() instanceof final ServerLevel serverLevel ? serverLevel : null;
this.level = player.getServer().getProfilePermissions(player.getGameProfile());
this.level = player.getServer().getProfilePermissions(player.nameAndId());
this.simpleName = player.getName().getString();
this.name = player.getDisplayName();
this.server = player.level().getServer();
@@ -92,7 +92,8 @@ public class SystemInfo
put("game_minor_target", c -> NumericValue.of(Vanilla.MinecraftServer_getReleaseTarget(c.server())[1]));
put("game_stable", c -> BooleanValue.of(SharedConstants.getCurrentVersion().stable()));
put("game_data_version", c -> NumericValue.of(SharedConstants.getCurrentVersion().dataVersion().version()));
put("game_pack_version", c -> NumericValue.of(SharedConstants.getCurrentVersion().packVersion(PackType.SERVER_DATA)));
put("game_pack_version", c -> NumericValue.of(SharedConstants.getCurrentVersion().packVersion(PackType.SERVER_DATA).major()));
put("game_pack_minor_version", c -> NumericValue.of(SharedConstants.getCurrentVersion().packVersion(PackType.SERVER_DATA).minor()));
put("server_ip", c -> StringValue.of(c.server().getLocalIp()));
put("server_whitelisted", c -> BooleanValue.of(c.server().isEnforceWhitelist()));
@@ -15,7 +15,6 @@ 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.level.progress.ChunkProgressListener;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.CustomSpawner;
import net.minecraft.world.level.Level;
@@ -628,7 +628,7 @@ public class EntityValue extends Value
{
return new StringValue("singleplayer");
}
boolean isowner = server.isSingleplayerOwner(p.getGameProfile());
boolean isowner = server.isSingleplayerOwner(p.nameAndId());
if (isowner)
{
return new StringValue("lan_host");
@@ -1217,7 +1217,7 @@ public class EntityValue extends Value
put("mount", (e, v) -> {
if (v instanceof EntityValue ev)
{
e.startRiding(ev.getEntity(), true);
e.startRiding(ev.getEntity(), true, true);
}
if (e instanceof ServerPlayer sp)
{
@@ -1233,7 +1233,7 @@ public class EntityValue extends Value
}
if (v instanceof EntityValue ev)
{
ev.getEntity().startRiding(e);
ev.getEntity().startRiding(e, true, true);
}
else if (v instanceof ListValue lv)
{
@@ -1241,7 +1241,7 @@ public class EntityValue extends Value
{
if (element instanceof EntityValue ev)
{
ev.getEntity().startRiding(e);
ev.getEntity().startRiding(e, true, true);
}
}
}