Skip to content

Commit

Permalink
Bump out of rc, a bunch of bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Patbox committed Sep 25, 2023
1 parent ab231f1 commit ff3e580
Show file tree
Hide file tree
Showing 14 changed files with 79 additions and 24 deletions.
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.20.2-rc2
yarn_mappings=1.20.2-rc2+build.2
minecraft_version=1.20.2
yarn_mappings=1.20.2+build.1
loader_version=0.14.22

#Fabric api
fabric_version=0.88.5+1.20.2
fabric_version=0.89.1+1.20.2

maven_group = eu.pb4

mod_version = 0.6.0-rc.3
mod_version = 0.6.0

minecraft_version_supported = ">=1.20.2-"

packet_tweaker_version = 0.5.0+1.20.2-rc1
mixin_extras_version = 0.2.0-rc.1
mixin_extras_version = 0.2.0-rc.2

is_stable = true
2 changes: 1 addition & 1 deletion polymer-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ dependencies {

//modRuntime "supercoder79:databreaker:0.2.7"

modCompileOnly('maven.modrinth:lithium:mc1.20.1-0.11.2')
modCompileOnly('maven.modrinth:lithium:mc1.20.2-0.12.0')

//modCompileOnly ('nl.theepicblock:PolyMc:5.1.0+1.19')
modCompileOnly('com.github.TheEpicBlock:PolyMc:5.1.0')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public interface PolymerHeadBlock extends PolymerBlock {
* @return Skin Value
*/
String getPolymerSkinValue(BlockState state, BlockPos pos, ServerPlayerEntity player);
default String getPolymerSkinSignature(BlockState state, BlockPos pos, ServerPlayerEntity player) {
return null;
};

default Block getPolymerBlock() {
return Blocks.PLAYER_HEAD;
Expand All @@ -35,7 +38,10 @@ default Block getPolymerBlock() {
* @return NbtCompound representing client-side
*/
default NbtCompound getPolymerHeadSkullOwner(BlockState state, BlockPos pos, ServerPlayerEntity player) {
return PolymerUtils.createSkullOwner(((PolymerHeadBlock) state.getBlock()).getPolymerSkinValue(state, pos, player));
return PolymerUtils.createSkullOwner(
((PolymerHeadBlock) state.getBlock()).getPolymerSkinValue(state, pos, player),
((PolymerHeadBlock) state.getBlock()).getPolymerSkinSignature(state, pos, player)
);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public final class PolymerUtils {
public static final String ID = "polymer";
public static final String NO_TEXTURE_HEAD_VALUE = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNGUyY2UzMzcyYTNhYzk3ZmRkYTU2MzhiZWYyNGIzYmM0OWY0ZmFjZjc1MWZlOWNhZDY0NWYxNWE3ZmI4Mzk3YyJ9fX0=";
private static final Set<FeatureFlag> ENABLED_FEATURE_FLAGS = new HashSet<>();

private PolymerUtils() {
}

Expand Down Expand Up @@ -155,30 +156,54 @@ public static TooltipContext getCreativeTooltipContext(@Nullable ServerPlayerEnt
return PolymerImplUtils.getTooltipContext(player).withCreative();
}

/**
* With 1.20.2, client logs errors when signature is missing, which might cause a lot of spam in some cases.
* This method will be un-deprecated if the issue gets fixed.
* <p>
* <a href="https://bugs.mojang.com/browse/MC-264966">MC-264966</a>
*/
@Deprecated
public static NbtCompound createSkullOwner(String value) {
return createSkullOwner(value, null);
}

/**
* Creates SkullOwner NbtCompound from provided skin value
*
* @param value Skin value
* @return NbtCompound representing SkullOwner
*/
public static NbtCompound createSkullOwner(String value) {
public static NbtCompound createSkullOwner(String value, String signature) {
NbtCompound skullOwner = new NbtCompound();
NbtCompound properties = new NbtCompound();
NbtCompound data = new NbtCompound();
NbtList textures = new NbtList();
textures.addElement(0, data);

data.putString("Value", value);
if (signature != null) {
data.putString("Signature", signature);
}
properties.put("textures", textures);
skullOwner.put("Properties", properties);
skullOwner.putIntArray("Id", new int[]{0, 0, 0, 0});

return skullOwner;
}

/**
* With 1.20.2, client logs errors when signature is missing, which might cause a lot of spam in some cases.
* This method will be un-deprecated if the issue gets fixed.
* <p>
* <a href="https://bugs.mojang.com/browse/MC-264966">MC-264966</a>
*/
@Deprecated
public static ItemStack createPlayerHead(String value) {
return createPlayerHead(value, null);
}

public static ItemStack createPlayerHead(String value, String signature) {
var stack = new ItemStack(Items.PLAYER_HEAD);
stack.getOrCreateNbt().put("SkullOwner", createSkullOwner(value));
stack.getOrCreateNbt().put("SkullOwner", createSkullOwner(value, signature));
return stack;
}

Expand All @@ -203,11 +228,7 @@ public static Path getClientJar() {
}

public static boolean isServerOnly(Object obj) {
return obj instanceof PolymerObject
|| (obj instanceof ItemStack stack && PolymerItemUtils.isPolymerServerItem(stack))
|| (obj instanceof EntityType<?> type && PolymerEntityUtils.isRegisteredEntityType(type))
|| (obj instanceof BlockEntityType<?> typeBE && PolymerBlockUtils.isPolymerBlockEntityType(typeBE))
|| (obj instanceof VillagerProfession villagerProfession && PolymerEntityUtils.getPolymerProfession(villagerProfession) != null);
return obj instanceof PolymerObject || (obj instanceof ItemStack stack && PolymerItemUtils.isPolymerServerItem(stack)) || (obj instanceof EntityType<?> type && PolymerEntityUtils.isRegisteredEntityType(type)) || (obj instanceof BlockEntityType<?> typeBE && PolymerBlockUtils.isPolymerBlockEntityType(typeBE)) || (obj instanceof VillagerProfession villagerProfession && PolymerEntityUtils.getPolymerProfession(villagerProfession) != null);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
public class ClientMetadataKeys {
public static final Identifier MINECRAFT_PROTOCOL = id("minecraft_protocol");
public static final Identifier BLOCKSTATE_BITS = id("core/blockstate_bits");
public static final Identifier ADVANCED_TOOLTIP = id("core/advanced_tooltip");
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ public static void register() {
PolymerClientNetworking.AFTER_DISABLE.register(InternalClientRegistry::disable);

PolymerClientNetworking.BEFORE_METADATA_SYNC.register(() -> {
PolymerClientNetworking.setClientMetadata(ClientMetadataKeys.ADVANCED_TOOLTIP, NbtByte.of(MinecraftClient.getInstance().options.advancedItemTooltips));
PolymerClientNetworking.setClientMetadata(ClientMetadataKeys.BLOCKSTATE_BITS, NbtInt.of(MathHelper.ceilLog2(Block.STATE_IDS.size())));
PolymerClientNetworking.setClientMetadata(ClientMetadataKeys.MINECRAFT_PROTOCOL, NbtInt.of(SharedConstants.getProtocolVersion()));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static void sendMultiBlockUpdate(ServerPlayNetworkHandler player, ChunkSe
}
}

if (blocks.isEmpty()) {
if (!blocks.isEmpty()) {
player.sendPacket(new CustomPayloadS2CPacket(new PolymerSectionUpdateS2CPayload(chunkPos, pos.toShortArray(), blocks.toIntArray())));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import xyz.nucleoid.packettweaker.PacketContext;

public record PolymerChangeTooltipC2SPayload(boolean advanced) implements VersionedPayload {
public static final Identifier ID = C2SPackets.WORLD_PICK_BLOCK;
public static final Identifier ID = C2SPackets.CHANGE_TOOLTIP;

@Override
public void write(PacketContext context, int version, PacketByteBuf buf) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import xyz.nucleoid.packettweaker.PacketContext;

public record PolymerPickEntityC2SPayload(int entityId, boolean control) implements VersionedPayload {
public static final Identifier ID = C2SPackets.WORLD_PICK_BLOCK;
public static final Identifier ID = C2SPackets.WORLD_PICK_ENTITY;

@Override
public void write(PacketContext context, int version, PacketByteBuf buf) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package eu.pb4.polymer.core.mixin.other;

import eu.pb4.polymer.core.api.block.BlockMapper;
import eu.pb4.polymer.core.impl.ClientMetadataKeys;
import eu.pb4.polymer.core.impl.interfaces.PolymerPlayNetworkHandlerExtension;
import eu.pb4.polymer.networking.api.PolymerNetworking;
import eu.pb4.polymer.networking.api.server.PolymerServerNetworking;
import net.minecraft.nbt.NbtByte;
import net.minecraft.network.ClientConnection;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.network.ConnectedClientData;
Expand Down Expand Up @@ -36,6 +40,9 @@ public abstract class ServerPlayNetworkHandlerMixin implements PolymerPlayNetwor
@Inject(method = "<init>", at = @At("TAIL"))
private void polymer$setupInitial(MinecraftServer server, ClientConnection connection, ServerPlayerEntity player, ConnectedClientData clientData, CallbackInfo ci) {
this.polymer$blockMapper = BlockMapper.getDefault(player);
var advTool = PolymerNetworking.getMetadata(connection, ClientMetadataKeys.ADVANCED_TOOLTIP, NbtByte.TYPE);

this.polymer$advancedTooltip = advTool != null && advTool.intValue() > 0;
}


Expand Down
2 changes: 1 addition & 1 deletion polymer-core/src/main/resources/polymer-core.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"block.packet.WorldEventS2CPacketMixin",
"block.storage.ChunkSectionMixin",
"block.storage.WorldChunkMixin",
"client.compat.emi_EmiScreenManager",
"command.ArgumentNodeMixin",
"command.CommandManagerMixin",
"compat.lithium_BlockPaletteMixin",
Expand Down Expand Up @@ -81,6 +80,7 @@
"other.TagPacketSerializerMixin"
],
"client": [
"client.compat.emi_EmiScreenManager",
"client.ClientPlayNetworkHandlerMixin",
"client.CreativeInventoryScreenAccessor",
"client.DebugHudMixin",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,34 @@
import eu.pb4.polymer.networking.api.payload.PayloadDecoder;
import eu.pb4.polymer.networking.api.payload.VersionedPayload;
import eu.pb4.polymer.networking.impl.ClientPackets;
import eu.pb4.polymer.networking.impl.ExtClientConnection;
import eu.pb4.polymer.networking.impl.ServerPackets;
import eu.pb4.polymer.networking.mixin.CustomPayloadC2SPacketAccessor;
import eu.pb4.polymer.networking.mixin.CustomPayloadS2CPacketAccessor;
import it.unimi.dsi.fastutil.ints.IntList;
import net.minecraft.nbt.NbtElement;
import net.minecraft.nbt.NbtType;
import net.minecraft.network.ClientConnection;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.network.packet.CustomPayload;
import net.minecraft.network.packet.s2c.common.CustomPayloadS2CPacket;
import net.minecraft.server.network.ServerCommonNetworkHandler;
import net.minecraft.util.Identifier;
import org.jetbrains.annotations.Nullable;

public final class PolymerNetworking {
private PolymerNetworking() {}

@Nullable
public static <T extends NbtElement> T getMetadata(ClientConnection handler, Identifier identifier, NbtType<T> type) {
var x = ExtClientConnection.of(handler).polymerNet$getMetadataMap().get(identifier);
if (x != null && x.getNbtType() == type) {
//noinspection unchecked
return (T) x;
}
return null;
}

public static <T extends ContextPayload> void registerS2CPayload(Identifier identifier, ContextPayload.Decoder<T> decoder) {
registerS2CPayload(identifier, 0, decoder);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ public abstract class ServerLoginNetworkHandlerMixin implements NetworkHandlerEx
return;
}
ci.cancel();
EarlyConfigurationConnectionMagic.handle(this.profile, SyncedClientOptions.createDefault(), (ServerLoginNetworkHandler) (Object) this, this.server, connection, (context) -> {
var defaultOptions = SyncedClientOptions.createDefault();
EarlyConfigurationConnectionMagic.handle(this.profile, defaultOptions, (ServerLoginNetworkHandler) (Object) this, this.server, connection, (context) -> {
((ExtClientConnection) connection).polymerNet$wrongPacketConsumer(context.storedPackets()::add);
connection.disableAutoRead();
var attr = ((ExtClientConnection) connection).polymerNet$getChannel().attr(ClientConnection.SERVERBOUND_PROTOCOL_KEY);
Expand All @@ -70,7 +71,9 @@ public abstract class ServerLoginNetworkHandlerMixin implements NetworkHandlerEx

if (connection.isOpen()) {
this.polymerNet$ignoreCall = true;
this.polymerNet$overrideOptions = context.options().getValue();
if (context.options().getValue() != defaultOptions) {
this.polymerNet$overrideOptions = context.options().getValue();
}
this.onEnterConfiguration(packet);
if (this.connection.getPacketListener() instanceof ServerConfigurationPacketListener listener) {
for (var packetx : context.storedPackets()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
"ServerCommonNetworkHandlerMixin",
"ServerConfigurationNetworkHandlerMixin",
"ServerLoginNetworkHandlerMixin",
"ServerPlayerEntityMixin",
"client.ClientCommonNetworkHandlerMixin"
"ServerPlayerEntityMixin"
],
"client": [
"client.ClientPlayNetworkHandlerMixin"
"client.ClientPlayNetworkHandlerMixin",
"client.ClientCommonNetworkHandlerMixin"
],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit ff3e580

Please sign in to comment.