Skip to content
This repository has been archived by the owner on Dec 8, 2024. It is now read-only.

Commit

Permalink
Fix scales not being added to the client + cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
MerchantPug committed Nov 13, 2023
1 parent f47c0b6 commit 1de8a09
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import virtuoel.pehkui.api.ScaleRegistries;
import virtuoel.pehkui.api.ScaleType;

import java.net.IDN;
import java.util.List;
import java.util.Map;
import java.util.Set;
Expand All @@ -34,7 +33,7 @@ public class ApoliScaleModifier<P> extends ScaleModifier {
private final Set<ResourceLocation> scalesToUpdate = Sets.newHashSet();
protected final Set<ResourceLocation> cachedScaleIds;
protected boolean hasLoggedWarn = false;
protected boolean addedScales = false;
private boolean addedScales = false;

public ApoliScaleModifier(P power, List<?> modifiers, Set<ResourceLocation> cachedScaleIds) {
this(-128.0F, power, modifiers, cachedScaleIds);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.google.common.collect.Sets;
import it.unimi.dsi.fastutil.floats.Float2FloatFunction;
import net.merchantpug.apugli.Apugli;
import net.merchantpug.apugli.network.s2c.integration.pehkui.MarkLerpedScaleReadyPacket;
import net.merchantpug.apugli.network.c2s.integration.pehkui.ResetScaleCheckPacket;
import net.merchantpug.apugli.platform.Services;
import net.minecraft.nbt.CompoundTag;
Expand Down Expand Up @@ -78,8 +77,6 @@ public CompoundTag serialize(CompoundTag tag) {
super.serialize(tag);
tag.putInt("Ticks", this.getTicks());
tag.putBoolean("ShouldTickDown", this.shouldTickDown);
if (!Float.isNaN(this.scaleCheckValue))
tag.putFloat("ScaleCheckValue", this.scaleCheckValue);
if (!this.lowerBoundScales.isEmpty()) {
ListTag cachedMaxScaleTag = new ListTag();
for (Map.Entry<ResourceLocation, Float> entry : this.lowerBoundScales.entrySet()) {
Expand Down Expand Up @@ -108,8 +105,6 @@ public void deserialize(CompoundTag tag) {
super.deserialize(tag);
this.setTicks(tag.getInt("Ticks"));
this.shouldTickDown = tag.getBoolean("ShouldTickDown");
if (tag.contains("ScaleCheckValue", Tag.TAG_FLOAT))
this.scaleCheckValue = tag.getFloat("ScaleCheckValue");
if (tag.contains("LowerBoundScales", Tag.TAG_LIST)) {
ListTag lowerBoundScalesTag = tag.getList("LowerBoundScales", Tag.TAG_COMPOUND);
for (int i = 0; i < lowerBoundScalesTag.size(); ++i) {
Expand Down Expand Up @@ -174,13 +169,7 @@ public void tick(LivingEntity entity, boolean calledFromNbt) {

if (hasResetScale || calledFromNbt) continue;

if (!entity.level().isClientSide() && !this.readyScales.contains(scaleTypeId)) {
this.readyScales.add(scaleTypeId);
if (!hasSentReadyPacket) {
Services.PLATFORM.sendS2CTrackingAndSelf(new MarkLerpedScaleReadyPacket(entity.getId(), this.getId()), entity);
hasSentReadyPacket = true;
}
}
this.readyScales.add(scaleTypeId);
}

if (!this.readyScales.isEmpty() && !entity.level().isClientSide()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static <P> void tickScalePowers(LivingEntity entity) {

modifier.addScales(entity, ApugliPowers.MODIFY_SCALE.get().getCachedScaleIds(power, entity).stream().toList());

if (!entity.level().isClientSide()) continue;
if (entity.level().isClientSide()) continue;

modifier.tick(entity, false);
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ of this software and associated documentation files (the "Software"), to deal
import net.merchantpug.apugli.network.c2s.UpdateKeysPressedPacket;
import net.merchantpug.apugli.network.c2s.integration.pehkui.ResetScaleCheckPacket;
import net.merchantpug.apugli.network.s2c.*;
import net.merchantpug.apugli.network.s2c.integration.pehkui.MarkLerpedScaleReadyPacket;
import net.merchantpug.apugli.network.s2c.integration.pehkui.SyncScalePacket;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.server.MinecraftServer;
Expand All @@ -57,7 +56,6 @@ public static void registerS2C() {
ClientPlayNetworking.registerReceiver(ExecuteEntityActionClientPacket.ID, createS2CHandler(ExecuteEntityActionClientPacket::decode, ExecuteEntityActionClientPacket::handle));
ClientPlayNetworking.registerReceiver(ExecuteBiEntityActionClientPacket.ID, createS2CHandler(ExecuteBiEntityActionClientPacket::decode, ExecuteBiEntityActionClientPacket::handle));
ClientPlayNetworking.registerReceiver(SyncScalePacket.ID, createS2CHandler(SyncScalePacket::decode, SyncScalePacket::handle));
ClientPlayNetworking.registerReceiver(MarkLerpedScaleReadyPacket.ID, createS2CHandler(MarkLerpedScaleReadyPacket::decode, MarkLerpedScaleReadyPacket::handle));
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import net.merchantpug.apugli.network.s2c.SyncKeyPressCapabilityPacket;
import net.merchantpug.apugli.network.s2c.SyncKeysLessenedPacket;
import net.merchantpug.apugli.network.s2c.UpdateUrlTexturesPacket;
import net.merchantpug.apugli.network.s2c.integration.pehkui.MarkLerpedScaleReadyPacket;
import net.merchantpug.apugli.network.s2c.integration.pehkui.SyncScalePacket;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerPlayer;
Expand Down Expand Up @@ -60,7 +59,6 @@ public static void register() {
INSTANCE.registerMessage(i++, ExecuteBiEntityActionServerPacket.class, ExecuteBiEntityActionServerPacket::encode, ExecuteBiEntityActionServerPacket::decode, ApugliPacketHandler.createC2SHandler(ExecuteBiEntityActionServerPacket::handle));
INSTANCE.registerMessage(i++, ForcePlayerPosePacket.class, ForcePlayerPosePacket::encode, ForcePlayerPosePacket::decode, ApugliPacketHandler.createS2CHandler(ForcePlayerPosePacket::handle));
INSTANCE.registerMessage(i++, SyncScalePacket.class, SyncScalePacket::encode, SyncScalePacket::decode, ApugliPacketHandler.createS2CHandler(SyncScalePacket::handle));
INSTANCE.registerMessage(i++, MarkLerpedScaleReadyPacket.class, MarkLerpedScaleReadyPacket::encode, MarkLerpedScaleReadyPacket::decode, ApugliPacketHandler.createS2CHandler(MarkLerpedScaleReadyPacket::handle));
INSTANCE.registerMessage(i++, ModifyEnchantmentLevelPacket.class, ModifyEnchantmentLevelPacket::encode, ModifyEnchantmentLevelPacket::decode, ApugliPacketHandler.createS2CHandler(ModifyEnchantmentLevelPacket::handle));
INSTANCE.registerMessage(i++, ResetScaleCheckPacket.class, ResetScaleCheckPacket::encode, ResetScaleCheckPacket::decode, ApugliPacketHandler.createC2SHandler(ResetScaleCheckPacket::handle));
}
Expand Down

0 comments on commit 1de8a09

Please sign in to comment.