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.
Browse files Browse the repository at this point in the history
  • Loading branch information
MerchantPug committed Nov 13, 2023
1 parent 0029bae commit f47c0b6
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ public void tick(LivingEntity entity, boolean calledFromNbt) {
boolean updatedScale = false;
List<ResourceLocation> scaleTypeIds = ApugliPowers.MODIFY_SCALE.get().getCachedScaleIds(power, entity).stream().toList();

addScales(entity, scaleTypeIds);

for (ResourceLocation scaleTypeId : scaleTypeIds) {
ScaleType scaleType = ScaleRegistries.getEntry(ScaleRegistries.SCALE_TYPES, scaleTypeId);
ScaleData scaleData = scaleType.getScaleData(entity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,6 @@ public void tick(LivingEntity entity, boolean calledFromNbt) {

boolean isActive = Services.POWER.isActive(power, entity);

addScales(entity, this.cachedScaleIds.stream().toList());

for (ResourceLocation scaleTypeId : this.cachedScaleIds) {
ScaleType scaleType = ScaleRegistries.getEntry(ScaleRegistries.SCALE_TYPES, scaleTypeId);
ScaleData scaleData = scaleType.getScaleData(entity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,11 @@ public static <P> void tickScalePowers(LivingEntity entity) {
}).toList()) {
ApoliScaleModifier<P> modifier = (ApoliScaleModifier<P>) ApugliPowers.MODIFY_SCALE.get().getApoliScaleModifier(power, entity);

if (modifier != null)
modifier.tick(entity, false);
modifier.addScales(entity, ApugliPowers.MODIFY_SCALE.get().getCachedScaleIds(power, entity).stream().toList());

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

modifier.tick(entity, false);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public LivingEntityMixin(EntityType<?> entityType, Level level) {

@Inject(method = "tick", at = @At("HEAD"))
private void apugli$tickModifyScale(CallbackInfo ci) {
if (!this.level().isClientSide() && FabricLoader.getInstance().isModLoaded("pehkui") && !Services.POWER.getPowers((LivingEntity) (Object) this, ApugliPowers.MODIFY_SCALE.get(), true).isEmpty())
if (FabricLoader.getInstance().isModLoaded("pehkui") && !Services.POWER.getPowers((LivingEntity) (Object) this, ApugliPowers.MODIFY_SCALE.get(), true).isEmpty())
PehkuiUtil.tickScalePowers((LivingEntity)(Object)this);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public static void onLivingTick(LivingEvent.LivingTickEvent event) {
}

IndividualisedEmptyStackUtil.addEntityToStack(event.getEntity());
if (!this.level().isClientSide() && ModList.get().isLoaded("pehkui") && !Services.POWER.getPowers(event.getEntity(), ApugliPowers.MODIFY_SCALE.get(), true).isEmpty())
if (ModList.get().isLoaded("pehkui") && !Services.POWER.getPowers(event.getEntity(), ApugliPowers.MODIFY_SCALE.get(), true).isEmpty())
PehkuiUtil.tickScalePowers(event.getEntity());

if (Services.POWER.hasPower(event.getEntity(), ApugliPowers.HOVER.get())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,9 @@ public ModifyScalePower() {
}

protected PowerData access(ConfiguredPower<FabricValueModifyingConfiguration, ?> configuration, IPowerContainer container) {
if (!ModList.get().isLoaded("pehkui")) {
return null;
}
return configuration.getPowerData(container, () -> new PowerData(configuration, container.getOwner()));
}

@Override
public void onAdded(ConfiguredPower<FabricValueModifyingConfiguration, ?> power, Entity entity) {
this.access(power, ApoliAPI.getPowerContainer(entity));
}

@Override
public void onRemoved(ConfiguredPower<FabricValueModifyingConfiguration, ?> power, Entity entity) {
if (entity instanceof LivingEntity living)
Expand Down

0 comments on commit f47c0b6

Please sign in to comment.