Skip to content

Commit d89a983

Browse files
committed
Update to 1.21.9
1 parent 5fe7af9 commit d89a983

File tree

14 files changed

+181
-52
lines changed

14 files changed

+181
-52
lines changed

build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
id 'fabric-loom' version '1.10.+'
2+
id 'fabric-loom' version '1.11.+'
33
id 'maven-publish'
44
}
55

@@ -28,6 +28,8 @@ sourceSets {
2828
}
2929

3030
loom {
31+
accessWidenerPath = file("src/main/resources/sgui.accesswidener")
32+
3133
runs {
3234
testmodClient {
3335
client()

gradle.properties

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ org.gradle.jvmargs=-Xmx1G
33

44
# Fabric Properties
55
# check these on https://fabricmc.net/versions.html
6-
minecraft_version=1.21.8
7-
yarn_mappings=1.21.8+build.1
8-
loader_version=0.16.14
6+
minecraft_version=1.21.9-pre1
7+
yarn_mappings=1.21.9-pre1+build.8
8+
loader_version=0.17.2
99

1010
#Fabric api
11-
fabric_version=0.129.0+1.21.8
11+
fabric_version=0.133.7+1.21.9
1212

1313
# Mod Properties
14-
mod_version = 1.10.2+1.21.8
14+
mod_version = 1.11.0-rc.1+1.21.9
1515
maven_group = eu.pb4
1616
archives_base_name = sgui
1717

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

src/main/java/eu/pb4/sgui/api/elements/AnimatedGuiElement.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ public ClickCallback getGuiCallback() {
8080
public ItemStack getItemStackForDisplay(GuiInterface gui) {
8181
int cFrame = this.frame;
8282

83-
if (gui.getPlayer().getServer() != null && this.lastTick != gui.getPlayer().getServer().getTicks()) {
83+
if (gui.getPlayer().getEntityWorld().getServer() != null && this.lastTick != gui.getPlayer().getEntityWorld().getServer().getTicks()) {
8484
this.tick += 1;
85-
this.lastTick = gui.getPlayer().getServer().getTicks();
85+
this.lastTick = gui.getPlayer().getEntityWorld().getServer().getTicks();
8686
}
8787
if (this.tick >= this.changeEvery) {
8888
this.tick = 0;

src/main/java/eu/pb4/sgui/api/elements/AnimatedGuiElementBuilder.java

Lines changed: 68 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
package eu.pb4.sgui.api.elements;
22

3+
import com.google.common.collect.ImmutableBiMap;
4+
import com.google.common.collect.ImmutableMultimap;
35
import com.mojang.authlib.GameProfile;
46
import com.mojang.authlib.minecraft.MinecraftProfileTextures;
57
import com.mojang.authlib.properties.Property;
68
import com.mojang.authlib.properties.PropertyMap;
9+
import com.mojang.datafixers.util.Either;
710
import eu.pb4.sgui.api.GuiHelpers;
11+
import eu.pb4.sgui.mixin.StaticAccessor;
812
import it.unimi.dsi.fastutil.objects.ReferenceSortedSets;
13+
import net.minecraft.client.ClientAssets;
14+
import net.minecraft.client.util.SkinTextures;
915
import net.minecraft.component.ComponentType;
1016
import net.minecraft.component.DataComponentTypes;
1117
import net.minecraft.component.type.CustomModelDataComponent;
@@ -26,6 +32,7 @@
2632
import net.minecraft.util.Identifier;
2733
import net.minecraft.util.Rarity;
2834
import net.minecraft.util.Unit;
35+
import net.minecraft.util.Util;
2936
import org.jetbrains.annotations.Nullable;
3037

3138
import java.util.*;
@@ -357,23 +364,70 @@ public AnimatedGuiElementBuilder unbreakable() {
357364
* server load the textures.
358365
*
359366
* @param profile the {@link GameProfile} of the owner
360-
* @param server the server instance, used to get the textures
361367
* @return this element builder
362368
*/
363-
public AnimatedGuiElementBuilder setSkullOwner(GameProfile profile, @Nullable MinecraftServer server) {
364-
if (profile.getId() != null && server != null) {
365-
if (server.getSessionService().getTextures(profile) == MinecraftProfileTextures.EMPTY) {
366-
var tmp = server.getSessionService().fetchProfile(profile.getId(), false);
367-
if (tmp != null) {
368-
profile = tmp.profile();
369-
}
370-
}
371-
369+
public AnimatedGuiElementBuilder setProfile(GameProfile profile) {
370+
if (!profile.properties().isEmpty()) {
371+
return this.setProfile(ProfileComponent.ofStatic(profile));
372+
}
373+
if (profile.name().isEmpty()) {
374+
return this.setProfile(ProfileComponent.ofDynamic(profile.id()));
375+
}
376+
if (profile.id().equals(Util.NIL_UUID)) {
377+
return this.setProfile(ProfileComponent.method_74889(profile.name()));
372378
}
373-
this.itemStack.set(DataComponentTypes.PROFILE, new ProfileComponent(profile));
374379
return this;
375380
}
376381

382+
public AnimatedGuiElementBuilder setProfile(String name) {
383+
return this.setProfile(ProfileComponent.method_74889(name));
384+
}
385+
386+
public AnimatedGuiElementBuilder setProfile(UUID uuid) {
387+
return this.setProfile(ProfileComponent.ofDynamic(uuid));
388+
}
389+
390+
public AnimatedGuiElementBuilder setProfile(Identifier textureId) {
391+
return this.setProfile(StaticAccessor.createStatic(Either.right(ProfileComponent.Data.field_63032),
392+
new SkinTextures.MannequinInfo(Optional.of(new ClientAssets.AssetInfo(textureId)), Optional.empty(),
393+
Optional.empty(), Optional.empty())));
394+
}
395+
396+
public AnimatedGuiElementBuilder setProfile(SkinTextures.MannequinInfo info) {
397+
return this.setProfile(StaticAccessor.createStatic(Either.right(ProfileComponent.Data.field_63032), info));
398+
}
399+
400+
public AnimatedGuiElementBuilder setProfile(ProfileComponent component) {
401+
this.itemStack.set(DataComponentTypes.PROFILE, component);
402+
return this;
403+
}
404+
405+
406+
public AnimatedGuiElementBuilder setProfileSkinTexture(String value) {
407+
return this.setProfileSkinTexture(value, null, null);
408+
}
409+
410+
public AnimatedGuiElementBuilder setProfileSkinTexture(String value, @Nullable String signature, @Nullable UUID uuid) {
411+
PropertyMap map = new PropertyMap(ImmutableMultimap.of("textures", new Property("textures", value, signature)));
412+
return this.setProfile(new GameProfile( uuid != null ? uuid : Util.NIL_UUID, "", map));
413+
}
414+
415+
/**
416+
* Sets the skull owner tag of a player head.
417+
* If the server parameter is not supplied it may lag the client while it loads the texture,
418+
* otherwise if the server is provided and the {@link GameProfile} contains a UUID then the
419+
* textures will be loaded by the server. This can take some time the first load,
420+
* however the skins are cached for later uses so its often less noticeable to let the
421+
* server load the textures.
422+
*
423+
* @param profile the {@link GameProfile} of the owner
424+
* @return this element builder
425+
*/
426+
@Deprecated
427+
public AnimatedGuiElementBuilder setSkullOwner(GameProfile profile, @Nullable MinecraftServer server) {
428+
return this.setProfile(profile);
429+
}
430+
377431
/**
378432
* Sets the skull owner tag of a player head.
379433
* This method uses raw values required by client to display the skin
@@ -382,6 +436,7 @@ public AnimatedGuiElementBuilder setSkullOwner(GameProfile profile, @Nullable Mi
382436
* @param value texture value used by client
383437
* @return this element builder
384438
*/
439+
@Deprecated
385440
public AnimatedGuiElementBuilder setSkullOwner(String value) {
386441
return this.setSkullOwner(value, null, null);
387442
}
@@ -396,11 +451,9 @@ public AnimatedGuiElementBuilder setSkullOwner(String value) {
396451
* @param uuid UUID of skin owner, if null default will be used
397452
* @return this element builder
398453
*/
454+
@Deprecated
399455
public AnimatedGuiElementBuilder setSkullOwner(String value, @Nullable String signature, @Nullable UUID uuid) {
400-
PropertyMap map = new PropertyMap();
401-
map.put("textures", new Property("textures", value, signature));
402-
this.itemStack.set(DataComponentTypes.PROFILE, new ProfileComponent(Optional.empty(), Optional.ofNullable(uuid), map));
403-
return this;
456+
return this.setProfileSkinTexture(value, signature, uuid);
404457
}
405458

406459
/**

src/main/java/eu/pb4/sgui/api/elements/GuiElementBuilder.java

Lines changed: 67 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
package eu.pb4.sgui.api.elements;
22

3+
import com.google.common.collect.ImmutableMultimap;
34
import com.mojang.authlib.GameProfile;
45
import com.mojang.authlib.minecraft.MinecraftProfileTextures;
56
import com.mojang.authlib.properties.Property;
67
import com.mojang.authlib.properties.PropertyMap;
8+
import com.mojang.datafixers.util.Either;
79
import eu.pb4.sgui.api.GuiHelpers;
10+
import eu.pb4.sgui.mixin.StaticAccessor;
811
import it.unimi.dsi.fastutil.objects.ReferenceSortedSets;
12+
import net.minecraft.client.ClientAssets;
13+
import net.minecraft.client.util.SkinTextures;
914
import net.minecraft.component.ComponentType;
1015
import net.minecraft.component.DataComponentTypes;
1116
import net.minecraft.component.type.CustomModelDataComponent;
@@ -26,6 +31,7 @@
2631
import net.minecraft.util.Identifier;
2732
import net.minecraft.util.Rarity;
2833
import net.minecraft.util.Unit;
34+
import net.minecraft.util.Util;
2935
import org.jetbrains.annotations.Nullable;
3036

3137
import java.util.*;
@@ -389,23 +395,70 @@ public GuiElementBuilder unbreakable() {
389395
* server load the textures.
390396
*
391397
* @param profile the {@link GameProfile} of the owner
392-
* @param server the server instance, used to get the textures
393398
* @return this element builder
394399
*/
395-
public GuiElementBuilder setSkullOwner(GameProfile profile, @Nullable MinecraftServer server) {
396-
if (profile.getId() != null && server != null) {
397-
if (server.getSessionService().getTextures(profile) == MinecraftProfileTextures.EMPTY) {
398-
var tmp = server.getSessionService().fetchProfile(profile.getId(), false);
399-
if (tmp != null) {
400-
profile = tmp.profile();
401-
}
402-
}
403-
400+
public GuiElementBuilder setProfile(GameProfile profile) {
401+
if (!profile.properties().isEmpty()) {
402+
return this.setProfile(ProfileComponent.ofStatic(profile));
403+
}
404+
if (profile.name().isEmpty()) {
405+
return this.setProfile(ProfileComponent.ofDynamic(profile.id()));
404406
}
405-
this.itemStack.set(DataComponentTypes.PROFILE, new ProfileComponent(profile));
407+
if (profile.id().equals(Util.NIL_UUID)) {
408+
return this.setProfile(ProfileComponent.method_74889(profile.name()));
409+
}
410+
return this;
411+
}
412+
413+
public GuiElementBuilder setProfile(String name) {
414+
return this.setProfile(ProfileComponent.method_74889(name));
415+
}
416+
417+
public GuiElementBuilder setProfile(UUID uuid) {
418+
return this.setProfile(ProfileComponent.ofDynamic(uuid));
419+
}
420+
421+
public GuiElementBuilder setProfile(Identifier textureId) {
422+
return this.setProfile(StaticAccessor.createStatic(Either.right(ProfileComponent.Data.field_63032),
423+
new SkinTextures.MannequinInfo(Optional.of(new ClientAssets.AssetInfo(textureId)), Optional.empty(),
424+
Optional.empty(), Optional.empty())));
425+
}
426+
427+
public GuiElementBuilder setProfile(SkinTextures.MannequinInfo info) {
428+
return this.setProfile(StaticAccessor.createStatic(Either.right(ProfileComponent.Data.field_63032), info));
429+
}
430+
431+
public GuiElementBuilder setProfile(ProfileComponent component) {
432+
this.itemStack.set(DataComponentTypes.PROFILE, component);
406433
return this;
407434
}
408435

436+
437+
public GuiElementBuilder setProfileSkinTexture(String value) {
438+
return this.setProfileSkinTexture(value, null, null);
439+
}
440+
441+
public GuiElementBuilder setProfileSkinTexture(String value, @Nullable String signature, @Nullable UUID uuid) {
442+
PropertyMap map = new PropertyMap(ImmutableMultimap.of("textures", new Property("textures", value, signature)));
443+
return this.setProfile(new GameProfile( uuid != null ? uuid : Util.NIL_UUID, "", map));
444+
}
445+
446+
/**
447+
* Sets the skull owner tag of a player head.
448+
* If the server parameter is not supplied it may lag the client while it loads the texture,
449+
* otherwise if the server is provided and the {@link GameProfile} contains a UUID then the
450+
* textures will be loaded by the server. This can take some time the first load,
451+
* however the skins are cached for later uses so its often less noticeable to let the
452+
* server load the textures.
453+
*
454+
* @param profile the {@link GameProfile} of the owner
455+
* @return this element builder
456+
*/
457+
@Deprecated
458+
public GuiElementBuilder setSkullOwner(GameProfile profile, @Nullable MinecraftServer server) {
459+
return this.setProfile(profile);
460+
}
461+
409462
/**
410463
* Sets the skull owner tag of a player head.
411464
* This method uses raw values required by client to display the skin
@@ -414,6 +467,7 @@ public GuiElementBuilder setSkullOwner(GameProfile profile, @Nullable MinecraftS
414467
* @param value texture value used by client
415468
* @return this element builder
416469
*/
470+
@Deprecated
417471
public GuiElementBuilder setSkullOwner(String value) {
418472
return this.setSkullOwner(value, null, null);
419473
}
@@ -428,11 +482,9 @@ public GuiElementBuilder setSkullOwner(String value) {
428482
* @param uuid UUID of skin owner, if null default will be used
429483
* @return this element builder
430484
*/
485+
@Deprecated
431486
public GuiElementBuilder setSkullOwner(String value, @Nullable String signature, @Nullable UUID uuid) {
432-
PropertyMap map = new PropertyMap();
433-
map.put("textures", new Property("textures", value, signature));
434-
this.itemStack.set(DataComponentTypes.PROFILE, new ProfileComponent(Optional.empty(), Optional.ofNullable(uuid), map));
435-
return this;
487+
return this.setProfileSkinTexture(value, signature, uuid);
436488
}
437489

438490
@Override

src/main/java/eu/pb4/sgui/api/gui/SignGui.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public class SignGui implements GuiInterface {
5757
*/
5858
public SignGui(ServerPlayerEntity player) {
5959
this.player = player;
60-
this.signEntity = new VirtualSignBlockEntity(player.getWorld(), new BlockPos(player.getBlockPos().getX(), Math.min(player.getWorld().getTopYInclusive(), player.getBlockPos().getY() + 5), player.getBlockPos().getZ()), Blocks.OAK_SIGN.getDefaultState());
60+
this.signEntity = new VirtualSignBlockEntity(player.getEntityWorld(), new BlockPos(player.getBlockPos().getX(), Math.min(player.getEntityWorld().getTopYInclusive(), player.getBlockPos().getY() + 5), player.getBlockPos().getZ()), Blocks.OAK_SIGN.getDefaultState());
6161
}
6262

6363
/**
@@ -166,7 +166,7 @@ public void close(boolean alreadyClosed) {
166166
this.open = false;
167167
this.reOpen = false;
168168

169-
this.player.networkHandler.sendPacket(new BlockUpdateS2CPacket(player.getWorld(), signEntity.getPos()));
169+
this.player.networkHandler.sendPacket(new BlockUpdateS2CPacket(player.getEntityWorld(), signEntity.getPos()));
170170

171171
if (alreadyClosed && this.player.currentScreenHandler == this.screenHandler) {
172172
this.player.onHandledScreenClosed();

src/main/java/eu/pb4/sgui/mixin/ServerPlayNetworkHandlerMixin.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,9 @@ public ServerPlayNetworkHandlerMixin(MinecraftServer server, ClientConnection co
294294
var pos = packet.getBlockHitResult().getBlockPos();
295295
handler.syncSelectedSlot();
296296

297-
this.sendPacket(new BlockUpdateS2CPacket(pos, this.player.getWorld().getBlockState(pos)));
297+
this.sendPacket(new BlockUpdateS2CPacket(pos, this.player.getEntityWorld().getBlockState(pos)));
298298
pos = pos.offset(packet.getBlockHitResult().getSide());
299-
this.sendPacket(new BlockUpdateS2CPacket(pos, this.player.getWorld().getBlockState(pos)));
299+
this.sendPacket(new BlockUpdateS2CPacket(pos, this.player.getEntityWorld().getBlockState(pos)));
300300
this.sendPacket(new PlayerActionResponseS2CPacket(packet.getSequence()));
301301

302302
ci.cancel();
@@ -316,9 +316,9 @@ public ServerPlayNetworkHandlerMixin(MinecraftServer server, ClientConnection co
316316
handler.syncOffhandSlot();
317317
}
318318

319-
this.sendPacket(new BlockUpdateS2CPacket(pos, this.player.getWorld().getBlockState(pos)));
319+
this.sendPacket(new BlockUpdateS2CPacket(pos, this.player.getEntityWorld().getBlockState(pos)));
320320
pos = pos.offset(packet.getDirection());
321-
this.sendPacket(new BlockUpdateS2CPacket(pos, this.player.getWorld().getBlockState(pos)));
321+
this.sendPacket(new BlockUpdateS2CPacket(pos, this.player.getEntityWorld().getBlockState(pos)));
322322
this.sendPacket(new PlayerActionResponseS2CPacket(packet.getSequence()));
323323
ci.cancel();
324324
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package eu.pb4.sgui.mixin;
2+
3+
import com.mojang.authlib.GameProfile;
4+
import com.mojang.datafixers.util.Either;
5+
import net.minecraft.client.util.SkinTextures;
6+
import net.minecraft.component.type.ProfileComponent;
7+
import org.spongepowered.asm.mixin.Mixin;
8+
import org.spongepowered.asm.mixin.gen.Invoker;
9+
10+
@Mixin(ProfileComponent.Static.class)
11+
public interface StaticAccessor {
12+
@Invoker("<init>")
13+
static ProfileComponent.Static createStatic(Either<GameProfile, ProfileComponent.Data> profileOrData, SkinTextures.MannequinInfo mannequinInfo) {
14+
throw new UnsupportedOperationException();
15+
}
16+
}

src/main/java/eu/pb4/sgui/virtual/merchant/VirtualMerchantScreenHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public ItemStack quickMove(PlayerEntity player, int index) {
8282
public void onClosed(PlayerEntity playerEntity) {
8383
super.onClosed(playerEntity);
8484
this.merchant.setCustomer(null);
85-
if (!playerEntity.getWorld().isClient) {
85+
if (!playerEntity.getEntityWorld().isClient()) {
8686
if (!playerEntity.isAlive() || playerEntity instanceof ServerPlayerEntity && ((ServerPlayerEntity)playerEntity).isDisconnected()) {
8787
ItemStack itemStack = this.merchantInventory.removeStack(0);
8888
if (!itemStack.isEmpty()) {

0 commit comments

Comments
 (0)