Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/api-10' into api-11
Browse files Browse the repository at this point in the history
  • Loading branch information
aromaa committed Apr 5, 2024
2 parents 3eff508 + 14d2d2b commit ce44b24
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import net.minecraft.server.level.ServerEntity;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.network.ServerPlayerConnection;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import org.spongepowered.asm.mixin.gen.Invoker;
Expand All @@ -35,7 +36,7 @@
@Mixin(targets = "net/minecraft/server/level/ChunkMap$TrackedEntity")
public interface ChunkMap_TrackedEntityAccessor {

@Accessor("seenBy") Set<ServerPlayer> accessor$seenBy();
@Accessor("seenBy") Set<ServerPlayerConnection> accessor$seenBy();

@Invoker("updatePlayer") void accessor$updatePlayer(ServerPlayer param0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ public final class EntityCategory {
@Setting
public final ItemSubCategory item = new ItemSubCategory();

@Setting
public final PaintingSubCategory painting = new PaintingSubCategory();

@ConfigSerializable
public static final class HumanSubCategory {

Expand All @@ -48,14 +45,6 @@ public static final class HumanSubCategory {
public int tabListRemoveDelay = 10;
}

@ConfigSerializable
public static final class PaintingSubCategory {

@Setting("respawn-delay")
@Comment("Number of ticks before a painting is respawned on clients when their art is changed")
public int respawnDelay = 2;
}

@ConfigSerializable
public static final class ItemSubCategory {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,18 @@
package org.spongepowered.common.data.provider.entity;

import net.minecraft.core.Holder;
import net.minecraft.network.protocol.game.ClientboundRemoveEntitiesPacket;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.network.ServerPlayerConnection;
import net.minecraft.world.entity.decoration.Painting;
import net.minecraft.world.entity.decoration.PaintingVariant;
import org.spongepowered.api.data.Keys;
import org.spongepowered.api.data.type.ArtType;
import org.spongepowered.api.scheduler.Task;
import org.spongepowered.common.SpongeCommon;
import org.spongepowered.common.accessor.server.level.ChunkMapAccessor;
import org.spongepowered.common.accessor.server.level.ChunkMap_TrackedEntityAccessor;
import org.spongepowered.common.accessor.world.entity.decoration.HangingEntityAccessor;
import org.spongepowered.common.accessor.world.entity.decoration.PaintingAccessor;
import org.spongepowered.common.config.SpongeGameConfigs;
import org.spongepowered.common.data.provider.DataProviderRegistrator;
import org.spongepowered.common.launch.Launch;
import org.spongepowered.common.util.SpongeTicks;

import java.util.ArrayList;
import java.util.List;

public final class PaintingData {

Expand Down Expand Up @@ -74,20 +66,10 @@ public static void register(final DataProviderRegistrator registrator) {
return true;
}

final List<ServerPlayer> players = new ArrayList<>();
for (final ServerPlayer player : paintingTracker.accessor$seenBy()) {
final ClientboundRemoveEntitiesPacket packet = new ClientboundRemoveEntitiesPacket(h.getId());
player.connection.send(packet);
players.add(player);
}
for (final ServerPlayer player : players) {
SpongeCommon.serverScheduler().submit(Task.builder()
.plugin(Launch.instance().commonPlugin())
.delay(new SpongeTicks(SpongeGameConfigs.getForWorld(h.level()).get().entity.painting.respawnDelay))
.execute(() -> {
player.connection.send(h.getAddEntityPacket()); // TODO does it also set the variant?
})
.build());
for (final ServerPlayerConnection playerConnection : paintingTracker.accessor$seenBy().toArray(new ServerPlayerConnection[0])) {
final ServerPlayer player = playerConnection.getPlayer();
paintingTracker.accessor$removePlayer(player);
paintingTracker.accessor$updatePlayer(player);
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.level.TicketType;
import net.minecraft.server.network.ServerPlayerConnection;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundSource;
import net.minecraft.util.RandomSource;
Expand Down Expand Up @@ -419,21 +420,21 @@ public abstract class EntityMixin implements EntityBridge, PlatformEntityBridge,
}

if (this.bridge$vanishState().invisible()) {
for (final ServerPlayer entityPlayerMP : trackerAccessor.accessor$seenBy()) {
trackerAccessor.accessor$removePlayer(entityPlayerMP);
for (final ServerPlayerConnection playerConnection : trackerAccessor.accessor$seenBy()) {
trackerAccessor.accessor$removePlayer(playerConnection.getPlayer());
}

if ((Entity) (Object) this instanceof ServerPlayer) {
for (final ServerPlayer entityPlayerMP : SpongeCommon.server().getPlayerList().getPlayers()) {
if ((Entity) (Object) this == entityPlayerMP) {
if ((Object) this == entityPlayerMP) {
continue;
}
entityPlayerMP.connection.send(new ClientboundPlayerInfoRemovePacket(List.of(this.uuid)));
}
}
} else {
for (final ServerPlayer entityPlayerMP : SpongeCommon.server().getPlayerList().getPlayers()) {
if ((Entity) (Object) this == entityPlayerMP) {
if ((Object) this == entityPlayerMP) {
continue;
}
if ((Entity) (Object) this instanceof ServerPlayer player) {
Expand Down

0 comments on commit ce44b24

Please sign in to comment.