Skip to content

Commit 770056c

Browse files
committed
chore: update to from api-13
2 parents cd1052a + 707b3f1 commit 770056c

File tree

6 files changed

+37
-5
lines changed

6 files changed

+37
-5
lines changed

src/main/java/org/spongepowered/common/entity/player/tab/SpongeTabList.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ private void addEntry(final ClientboundPlayerInfoUpdatePacket.Entry entry) {
151151
entry.latency(),
152152
(GameMode) (Object) entry.gameMode(),
153153
entry.listed(),
154+
entry.listOrder(),
154155
entry.chatSession() == null ? null : entry.chatSession().profilePublicKey()
155156
), false);
156157
}
@@ -190,11 +191,10 @@ public Optional<TabListEntry> removeEntry(final UUID uniqueId) {
190191
@SuppressWarnings("ConstantConditions")
191192
void sendUpdate(final TabListEntry entry, final EnumSet<ClientboundPlayerInfoUpdatePacket.Action> actions) {
192193
final ClientboundPlayerInfoUpdatePacket packet = new ClientboundPlayerInfoUpdatePacket(actions, List.of());
193-
int listOrder = 0; // TODO expose to API
194194
final RemoteChatSession.Data chatSessionData = ((SpongeTabListEntry) entry).profilePublicKey() == null ? null : new RemoteChatSession.Data(entry.profile().uuid(), ((SpongeTabListEntry) entry).profilePublicKey());
195195
final net.minecraft.network.chat.Component displayName = entry.displayName().isPresent() ? SpongeAdventure.asVanilla(entry.displayName().get()) : null;
196196
final ClientboundPlayerInfoUpdatePacket.Entry data = new ClientboundPlayerInfoUpdatePacket.Entry(entry.profile().uniqueId(), SpongeGameProfile.toMcProfile(entry.profile()),
197-
entry.listed(), entry.latency(), (GameType) (Object) entry.gameMode(), displayName, listOrder, chatSessionData);
197+
entry.listed(), entry.latency(), (GameType) (Object) entry.gameMode(), displayName, entry.weight(), chatSessionData);
198198
((ClientboundPlayerInfoUpdatePacketAccessor) packet).accessor$entries(List.of(data));
199199
this.player.connection.send(packet);
200200
}

src/main/java/org/spongepowered/common/entity/player/tab/SpongeTabListEntry.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,21 @@ public final class SpongeTabListEntry implements TabListEntry {
5252
private int latency;
5353
private GameMode gameMode;
5454
private boolean listed;
55+
private int weight;
5556
private boolean updateWithoutSend;
5657
private final ProfilePublicKey.Data profilePublicKey;
5758

5859
public SpongeTabListEntry(
5960
final TabList list, final GameProfile profile, @Nullable final Component displayName, final int latency, final GameMode gameMode,
60-
final boolean listed, final ProfilePublicKey.Data profilePublicKey) {
61+
final boolean listed, final int weight, final ProfilePublicKey.Data profilePublicKey) {
6162
Preconditions.checkState(list instanceof SpongeTabList, "list is not a SpongeTabList");
6263
this.list = (SpongeTabList) list;
6364
this.profile = Objects.requireNonNull(profile, "profile");
6465
this.displayName = displayName;
6566
this.latency = latency;
6667
this.gameMode = Objects.requireNonNull(gameMode, "game mode");
6768
this.listed = listed;
69+
this.weight = weight;
6870
this.profilePublicKey = profilePublicKey;
6971
}
7072

@@ -126,6 +128,18 @@ public SpongeTabListEntry setListed(boolean listed) {
126128
return this;
127129
}
128130

131+
@Override
132+
public int weight() {
133+
return this.weight;
134+
}
135+
136+
@Override
137+
public SpongeTabListEntry setWeight(int weight) {
138+
this.weight = weight;
139+
this.sendUpdate(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_LIST_ORDER);
140+
return this;
141+
}
142+
129143
public ProfilePublicKey.Data profilePublicKey() {
130144
return this.profilePublicKey;
131145
}

src/main/java/org/spongepowered/common/entity/player/tab/TabListEntryBuilder.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public final class TabListEntryBuilder implements TabListEntry.Builder {
4444
private int latency;
4545
private boolean listed = true;
4646
private @Nullable GameMode gameMode;
47+
private int weight;
4748

4849
@Override
4950
public TabListEntry.Builder list(TabList list) {
@@ -81,13 +82,19 @@ public TabListEntry.Builder listed(boolean listed) {
8182
return this;
8283
}
8384

85+
@Override
86+
public TabListEntry.Builder weight(int weight) {
87+
this.weight = weight;
88+
return this;
89+
}
90+
8491
@Override
8592
public TabListEntry build() {
8693
Preconditions.checkState(this.list != null, "list must be set");
8794
Preconditions.checkState(this.profile != null, "profile must be set");
8895
Preconditions.checkState(this.gameMode != null, "game mode must be set");
8996

90-
return new SpongeTabListEntry(this.list, this.profile, this.displayName, this.latency, this.gameMode, this.listed, null);
97+
return new SpongeTabListEntry(this.list, this.profile, this.displayName, this.latency, this.gameMode, this.listed, this.weight, null);
9198
}
9299

93100
@Override
@@ -97,6 +104,7 @@ public TabListEntry.Builder from(TabListEntry value) {
97104
this.displayName = value.displayName().orElse(null);
98105
this.latency = value.latency();
99106
this.gameMode = Objects.requireNonNull(value.gameMode(), "game mode");
107+
this.weight = value.weight();
100108
return this;
101109
}
102110

@@ -107,6 +115,7 @@ public TabListEntry.Builder reset() {
107115
this.displayName = null;
108116
this.latency = 0;
109117
this.gameMode = null;
118+
this.weight = 0;
110119
return this;
111120
}
112121

src/mixins/java/org/spongepowered/common/mixin/tracker/server/level/ServerLevelMixin_Tracker.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,14 @@ public abstract class ServerLevelMixin_Tracker extends LevelMixin_Tracker implem
373373
this.tracker$apiExplosion = apiExplosion;
374374
}
375375

376+
@Inject(method = "explode", cancellable = true, at = @At(value = "INVOKE",
377+
target = "Lnet/minecraft/world/level/ServerExplosion;explode()V", shift = At.Shift.AFTER))
378+
private void tracker$onCancelled(final CallbackInfo ci) {
379+
if (this.tracker$apiExplosion == null) {
380+
ci.cancel();
381+
}
382+
}
383+
376384
/**
377385
* See {@link net.minecraft.client.multiplayer.ClientPacketListener#handleExplosion} for client side handling
378386
*/

vanilla/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ minecraft {
301301
// jvmArgs("-Dbsl.debug=true") // Uncomment to debug bootstrap classpath
302302
mainClass("net.minecraftforge.bootstrap.ForgeBootstrap")
303303

304+
// Configure resources
304305
jvmArgs("-Dsponge.dev.root=" + project.rootDir)
305306
jvmArgs("-Dsponge.dev.boot=$bootFileNames")
306307
jvmArgs("-Dsponge.dev.gameShaded=$gameShadedFileNames")

0 commit comments

Comments
 (0)