Skip to content

Commit

Permalink
chore: start update to 24w45a
Browse files Browse the repository at this point in the history
A couple of changes:
- There's a new shadow styling for chat
- PlayerList items can have 'showHat'
- ItemModel custom data is totally broken
- Structures got an added registry access for placement
- Chunk Region tickets lost POST_TELEPORT entirely, this might be worth looking into a functional replacement or not
- Client menu changes, needs fixing
  • Loading branch information
gabizou committed Nov 14, 2024
1 parent b666fd3 commit 34d90f9
Show file tree
Hide file tree
Showing 20 changed files with 87 additions and 64 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ mixinConfigs=mixins.sponge.accessors.json,mixins.sponge.api.json,mixins.sponge.c
mixins.sponge.tracker.json,mixins.sponge.ipforward.json,mixins.sponge.optimization.json
superClassChanges=common.superclasschange

minecraftVersion=1.21.3
minecraftVersion=24w45a
recommendedVersion=0-SNAPSHOT

org.gradle.dependency.verification.console=verbose
Expand Down
8 changes: 8 additions & 0 deletions gradle/verification-metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1232,6 +1232,14 @@
<sha256 value="d3bfc56998b7db90b46c8909c6c8a222b98437fda196cf5a0ede11c7085d28e2" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.mojang" name="authlib" version="6.0.57">
<artifact name="authlib-6.0.57.jar">
<sha256 value="e40ec0926a408aa05faf902f05dcde7e5f6255f6eeeb17f1e7ffb68b369d809a" origin="Generated by Gradle"/>
</artifact>
<artifact name="authlib-6.0.57.module">
<sha256 value="81034a34ae135cae2671386a6e763183c6e04a6250b9ed5bd2128faf90dc9c8d" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.mojang" name="blocklist" version="1.0.10">
<artifact name="blocklist-1.0.10.jar">
<sha256 value="830bfd639c8db49236bbd8e45d3a2b8c96c56ff654a10118654958a6235d4c44" origin="Generated by Gradle"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,22 @@
import net.minecraft.network.chat.Style;
import net.minecraft.network.chat.TextColor;
import net.minecraft.resources.ResourceLocation;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import org.spongepowered.asm.mixin.gen.Invoker;
import org.spongepowered.common.UntransformedInvokerError;

import javax.annotation.Nullable;
import java.util.Optional;

@Mixin(Style.class)
public interface StyleAccessor {

@Invoker("<init>")
static Style invoker$new(final @Nullable TextColor color, final @Nullable Boolean bold, final @Nullable Boolean italic,
final @Nullable Boolean underlined, final @Nullable Boolean strikethrough, final @Nullable Boolean obfuscated,
final @Nullable ClickEvent clickEvent, final @Nullable HoverEvent hoverEvent, final @Nullable String insertion,
final @Nullable ResourceLocation font) {
static Style invoker$new(final @Nullable TextColor color, final @Nullable Integer shadowColor, final @Nullable Boolean bold, final @Nullable Boolean italic,
final @Nullable Boolean underlined, final @Nullable Boolean strikethrough, final @Nullable Boolean obfuscated,
final @Nullable ClickEvent clickEvent, final @Nullable HoverEvent hoverEvent, final @Nullable String insertion,
final @Nullable ResourceLocation font) {
throw new UntransformedInvokerError();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,15 @@
package org.spongepowered.common.accessor.network.protocol.game;

import net.minecraft.network.protocol.game.ServerboundMoveVehiclePacket;
import net.minecraft.world.phys.Vec3;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.gen.Accessor;

@Mixin(ServerboundMoveVehiclePacket.class)
public interface ServerboundMoveVehiclePacketAccessor {

@Accessor("x") @Mutable void accessor$x(final double x);

@Accessor("y") @Mutable void accessor$y(final double y);

@Accessor("z") @Mutable void accessor$z(final double z);
@Accessor("position") @Mutable void accessor$position(final Vec3 position);

@Accessor("yRot") @Mutable void accessor$yRot(final float yRot);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static void register(final DataProviderRegistrator registrator) {
if (equippable == null) {
return null;
}
return equippable.model()
return equippable.assetId()
.map(rl -> (ResourceKey) (Object) rl)
.flatMap(rk -> RegistryTypes.ARMOR_MATERIAL.get().findEntry(rk))
.map(RegistryEntry::value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ public static void register(final DataProviderRegistrator registrator) {
.get(h -> (ItemType) h.getItem().getCraftingRemainder().getItem())
.create(Keys.DISPLAY_NAME)
.get(h -> SpongeAdventure.asAdventure(h.getDisplayName()))
.create(Keys.CUSTOM_MODEL_DATA)
.get(h -> h.getOrDefault(DataComponents.CUSTOM_MODEL_DATA, CustomModelData.DEFAULT).value())
.set((h, v) -> h.set(DataComponents.CUSTOM_MODEL_DATA, new CustomModelData(v)))
.delete(h -> h.remove(DataComponents.CUSTOM_MODEL_DATA))
// .create(Keys.CUSTOM_MODEL_DATA)
// .get(h -> h.getOrDefault(DataComponents.CUSTOM_MODEL_DATA, CustomModelData.EMPTY))
// .set((h, v) -> h.set(DataComponents.CUSTOM_MODEL_DATA, new CustomModelData(v)))
// .delete(h -> h.remove(DataComponents.CUSTOM_MODEL_DATA))
.create(Keys.CUSTOM_NAME)
.get(h -> {
if (h.has(DataComponents.CUSTOM_NAME)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ public void process(final double x, final double y, final double z, final List<P
final ClientboundLevelParticlesPacket packet = new ClientboundLevelParticlesPacket(
this.particleData,
true,
true,
posX, posY, posZ,
offX, offY, offZ,
0.0F,
Expand All @@ -263,6 +264,7 @@ public void process(final double x, final double y, final double z, final List<P
final ClientboundLevelParticlesPacket packet = new ClientboundLevelParticlesPacket(
this.particleData,
true,
true,
px0, py0, pz0,
velocityX, velocityY, velocityZ,
1f,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ public ClientboundPlayerInfoUpdatePacket createPlayerListPacket(final EnumSet<Cl
final ClientboundPlayerInfoUpdatePacket packet = new ClientboundPlayerInfoUpdatePacket(actions, List.of());

((ClientboundPlayerInfoUpdatePacketAccessor) packet).accessor$entries(List.of(
new ClientboundPlayerInfoUpdatePacket.Entry(this.uuid, this.fakeProfile.gameProfile(), false, 0, GameType.DEFAULT_MODE, this.getDisplayName(), 0, null)));
new ClientboundPlayerInfoUpdatePacket.Entry(this.uuid, this.fakeProfile.gameProfile(), false, 0, GameType.DEFAULT_MODE, this.getDisplayName(), false, 0, null)));
return packet;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ void sendUpdate(final TabListEntry entry, final EnumSet<ClientboundPlayerInfoUpd
final RemoteChatSession.Data chatSessionData = ((SpongeTabListEntry) entry).profilePublicKey() == null ? null : new RemoteChatSession.Data(entry.profile().uuid(), ((SpongeTabListEntry) entry).profilePublicKey());
final net.minecraft.network.chat.Component displayName = entry.displayName().isPresent() ? SpongeAdventure.asVanilla(entry.displayName().get()) : null;
final ClientboundPlayerInfoUpdatePacket.Entry data = new ClientboundPlayerInfoUpdatePacket.Entry(entry.profile().uniqueId(), SpongeGameProfile.toMcProfile(entry.profile()),
entry.listed(), entry.latency(), (GameType) (Object) entry.gameMode(), displayName, listOrder, chatSessionData);
entry.listed(), entry.latency(), (GameType) (Object) entry.gameMode(), displayName, false, listOrder, chatSessionData);
((ClientboundPlayerInfoUpdatePacketAccessor) packet).accessor$entries(List.of(data));
this.player.connection.send(packet);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ protected Optional<WitherSkull> createProjectile(final LivingEntity source, fina
@Override
protected Optional<FishingBobber> createProjectile(final LivingEntity source, final ServerLocation loc) {
if (source instanceof Player) {
final FishingHook hook = new FishingHook((Player) source, source.level(), 0, 0, new ItemStack(Items.FISHING_ROD));
final FishingHook hook = new FishingHook((Player) source, source.level(), 0, 0);
hook.setPos(loc.x(), loc.y(), loc.z());
return ProjectileUtil.doLaunch(loc.world(), (FishingBobber) hook);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
import net.minecraft.core.Holder;
import net.minecraft.core.HolderSet;
import net.minecraft.core.SectionPos;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.RegistryOps;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerChunkCache;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.MobCategory;
Expand Down Expand Up @@ -73,8 +75,20 @@ public boolean place(final ServerWorld world, final Vector3i pos) {
// see PlaceCommand#placeStructure
final ServerLevel level = (ServerLevel) world;
final ServerChunkCache chunkSource = level.getChunkSource();
final StructureStart start = ((Structure) (Object) this).generate(level.registryAccess(), chunkSource.getGenerator(), chunkSource.getGenerator().getBiomeSource(),
chunkSource.randomState(), level.getStructureManager(), level.getSeed(), new ChunkPos(VecHelper.toBlockPos(pos)), 0, level, b -> true);
final var key = level.registryAccess().lookupOrThrow(Registries.STRUCTURE).wrapAsHolder((Structure) (Object) this);
final StructureStart start = ((Structure) (Object) this).generate(
key,
level.dimension(),
level.registryAccess(),
chunkSource.getGenerator(),
chunkSource.getGenerator().getBiomeSource(),
chunkSource.randomState(),
level.getStructureManager(),
level.getSeed(),
new ChunkPos(VecHelper.toBlockPos(pos)),
0,
level,
ignored -> true);

if (!start.isValid()) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public abstract class StyleImplMixin implements StyleBridge {
this.bridge$vanilla = StyleAccessor.invoker$new(
// color
SpongeAdventure.asVanillaNullable($this.color()),
null,
// decorations
SpongeAdventure.asVanillaNullable($this.decoration(TextDecoration.BOLD)),
SpongeAdventure.asVanillaNullable($this.decoration(TextDecoration.ITALIC)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ private static void performTeleport(CommandSourceStack source, Entity entityIn,
if (entityIn instanceof ServerPlayer sp) {

ChunkPos chunkpos = new ChunkPos(new BlockPos((int) actualX, (int) actualY, (int) actualZ));
worldIn.getChunkSource().addRegionTicket(TicketType.POST_TELEPORT, chunkpos, 1, entityIn.getId());
worldIn.getChunkSource().addRegionTicket(TicketType.FORCED, chunkpos, 1, chunkpos);

entityIn.stopRiding();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public abstract class ServerPlayerMixin extends PlayerMixin implements SubjectBr
final var thisPlayer = ((net.minecraft.server.level.ServerPlayer) (Object) this);

final ChunkPos chunkPos = new ChunkPos(VecHelper.toBlockPos(pos));
level.getChunkSource().addRegionTicket(TicketType.POST_TELEPORT, chunkPos, 1, thisPlayer.getId());
level.getChunkSource().addRegionTicket(TicketType.FORCED, chunkPos, 1, chunkPos);

thisPlayer.stopRiding();
if (thisPlayer.isSleeping()) {
Expand Down Expand Up @@ -425,9 +425,8 @@ public boolean teleportTo(final ServerLevel world,
frame.addContext(EventContextKeys.MOVEMENT_TYPE, MovementTypes.PLUGIN);
}

final var thisPlayer = (net.minecraft.server.level.ServerPlayer) (Object) this;
return this.bridge$changeDimension(new TeleportTransition(world, new Vec3(x, y, z), Vec3.ZERO, yaw, pitch, relative,
e -> world.getChunkSource().addRegionTicket(TicketType.POST_TELEPORT, e.chunkPosition(), 1, thisPlayer.getId()))) != null;
e -> world.getChunkSource().addRegionTicket(TicketType.FORCED, e.chunkPosition(), 1, e.chunkPosition()))) != null;
}
}

Expand Down Expand Up @@ -698,7 +697,7 @@ public void die(final DamageSource cause) {
final LivingEntity livingentity = this.shadow$getKillCredit();
if (livingentity != null) {
this.shadow$awardStat(Stats.ENTITY_KILLED_BY.get(livingentity.getType()));
livingentity.awardKillScore((net.minecraft.server.level.ServerPlayer) (Object) this, this.deathScore, cause);
livingentity.awardKillScore((net.minecraft.server.level.ServerPlayer) (Object) this, cause);
this.shadow$createWitherRose(livingentity);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,16 +293,17 @@ public abstract class ServerGamePacketListenerImplMixin extends ServerCommonPack
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;getControllingPassenger()Lnet/minecraft/world/entity/LivingEntity;")
)
private void impl$handleVehicleMoveEvent(final ServerboundMoveVehiclePacket param0, final CallbackInfo ci) {
final ServerboundMoveVehiclePacketAccessor packet = (ServerboundMoveVehiclePacketAccessor) param0;
final ServerboundMoveVehiclePacketAccessor packet = (ServerboundMoveVehiclePacketAccessor) (Object) param0;
final Entity rootVehicle = this.player.getRootVehicle();
final Vector3d fromRotation = new Vector3d(rootVehicle.getYRot(), rootVehicle.getXRot(), 0);

// Use the position of the last movement with an event or the current player position if never called
// We need this because we ignore very small position changes as to not spam as many move events.
final Vector3d fromPosition = VecHelper.toVector3d(rootVehicle.position());

final Vector3d originalToPosition = new Vector3d(param0.getX(), param0.getY(), param0.getZ());
final Vector3d originalToRotation = new Vector3d(param0.getYRot(), param0.getXRot(), 0);
final var position = param0.position();
final Vector3d originalToPosition = new Vector3d(position.x, position.y(), position.z());
final Vector3d originalToRotation = new Vector3d(param0.yRot(), param0.xRot(), 0);

// common checks and throws are done here.
final @Nullable Vector3d toPosition = SpongeCommonEventFactory.callMoveEvent(
Expand All @@ -325,20 +326,19 @@ public abstract class ServerGamePacketListenerImplMixin extends ServerCommonPack
if (!fromRotation.equals(toRotation)) {
rootVehicle.absMoveTo(rootVehicle.getX(), rootVehicle.getY(), rootVehicle.getZ(), (float) toRotation.y(), (float) toRotation.x());
}
this.connection.send(new ClientboundMoveVehiclePacket(rootVehicle));
this.connection.send(ClientboundMoveVehiclePacket.fromEntity(rootVehicle));
ci.cancel();
return;
}

if (!toPosition.equals(originalToPosition) || !toRotation.equals(originalToRotation)) {
// notify the client about the new position
rootVehicle.absMoveTo(toPosition.x(), toPosition.y(), toPosition.z(), (float) toRotation.y(), (float) toRotation.x());
this.connection.send(new ClientboundMoveVehiclePacket(rootVehicle));
this.connection.send(ClientboundMoveVehiclePacket.fromEntity(rootVehicle));

// update the packet, let MC take care of the rest.
packet.accessor$x(toPosition.x());
packet.accessor$y(toPosition.y());
packet.accessor$z(toPosition.z());
final var newPos = VecHelper.toVanillaVector3d(toPosition);
packet.accessor$position(newPos);
packet.accessor$yRot((float) toRotation.x());
packet.accessor$xRot((float) toRotation.y());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ public abstract class LivingEntityMixin extends EntityMixin implements LivingEnt
// @formatter:off
@Shadow protected int useItemRemaining;
@Shadow protected boolean dead;
@Shadow protected int deathScore;
@Shadow protected ItemStack useItem;
@Shadow @Nullable private DamageSource lastDamageSource;
@Shadow private long lastDamageStamp;
Expand Down
Loading

0 comments on commit 34d90f9

Please sign in to comment.