From 592981706886b8db5483a89fc2071f5a632b61bb Mon Sep 17 00:00:00 2001 From: mrsterner Date: Tue, 26 Mar 2024 22:42:13 +0100 Subject: [PATCH] fix #26 --- build.gradle | 2 +- gradle.properties | 4 ++-- gradle/wrapper/gradle-wrapper.properties | 2 +- .../dev/mrsterner/besmirchment/common/Besmirchment.java | 7 +++++-- .../besmirchment/common/entity/BeelzebubEntity.java | 6 ++++-- .../besmirchment/common/entity/WerepyreEntity.java | 5 ++++- .../mrsterner/besmirchment/mixin/LivingEntityMixin.java | 8 ++++++-- .../mixin/TransformationAbilityPacketMixin.java | 7 +++++-- 8 files changed, 28 insertions(+), 13 deletions(-) diff --git a/build.gradle b/build.gradle index cec0a08..a9c2ef1 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '1.3-SNAPSHOT' + id 'fabric-loom' version '1.5-SNAPSHOT' id 'maven-publish' } diff --git a/gradle.properties b/gradle.properties index 43bc8f3..b574b3a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,12 +7,12 @@ minecraft_version=1.20.1 yarn_mappings=1.20.1+build.10 loader_version=0.15.3 # Mod Properties -mod_version=1.20.1-3 +mod_version=1.20.1-4 maven_group=dev.mrsterner.besmirchment archives_base_name=besmirchment # Dependencies # check this on https://modmuss50.me/fabric.html -bewitchment_version=5017964 +bewitchment_version=5205373 cardinal_components_version=5.2.2 fabric_permissions_api_version=0.1-SNAPSHOT diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 59bc51a..27313fb 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/dev/mrsterner/besmirchment/common/Besmirchment.java b/src/main/java/dev/mrsterner/besmirchment/common/Besmirchment.java index 0051860..b449bd8 100644 --- a/src/main/java/dev/mrsterner/besmirchment/common/Besmirchment.java +++ b/src/main/java/dev/mrsterner/besmirchment/common/Besmirchment.java @@ -32,6 +32,7 @@ import net.minecraft.entity.effect.StatusEffects; import net.minecraft.entity.passive.AnimalEntity; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.sound.SoundEvents; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; @@ -110,8 +111,10 @@ public void onInitialize() { transformationComponent.getTransformation().onRemoved(playerEntity); transformationComponent.setTransformation(BSMTransformations.WEREPYRE); transformationComponent.getTransformation().onAdded(playerEntity); - PlayerLookup.tracking(playerEntity).forEach(foundPlayer -> SpawnSmokeParticlesPacket.send(foundPlayer, playerEntity)); - SpawnSmokeParticlesPacket.send(playerEntity, playerEntity); + if (playerEntity instanceof ServerPlayerEntity serverPlayerEntity) { + PlayerLookup.tracking(playerEntity).forEach(foundPlayer -> SpawnSmokeParticlesPacket.send(foundPlayer, playerEntity)); + SpawnSmokeParticlesPacket.send(serverPlayerEntity, playerEntity); + } playerEntity.getWorld().playSound(null, playerEntity.getBlockPos(), BWSoundEvents.ENTITY_GENERIC_CURSE, playerEntity.getSoundCategory(), 1, 1); int variant = -1; if (source.getSource() instanceof WerepyreEntity) { diff --git a/src/main/java/dev/mrsterner/besmirchment/common/entity/BeelzebubEntity.java b/src/main/java/dev/mrsterner/besmirchment/common/entity/BeelzebubEntity.java index f9cb5ee..bfda01e 100644 --- a/src/main/java/dev/mrsterner/besmirchment/common/entity/BeelzebubEntity.java +++ b/src/main/java/dev/mrsterner/besmirchment/common/entity/BeelzebubEntity.java @@ -196,8 +196,10 @@ protected ActionResult interactMob(PlayerEntity player, Hand hand) { if (!player.isCreative()) { stack.decrement(1); } - PlayerLookup.tracking(player).forEach(foundPlayer -> SpawnSmokeParticlesPacket.send(foundPlayer, player)); - SpawnSmokeParticlesPacket.send(player, player); + if (player instanceof ServerPlayerEntity serverPlayerEntity) { + PlayerLookup.tracking(player).forEach(foundPlayer -> SpawnSmokeParticlesPacket.send(foundPlayer, player)); + SpawnSmokeParticlesPacket.send(serverPlayerEntity, player); + } getWorld().playSound(null, getBlockPos(), BWSoundEvents.ENTITY_GENERIC_PLING, player.getSoundCategory(), 1, 1); if (BWComponents.TRANSFORMATION_COMPONENT.get(player).isAlternateForm()) { TransformationAbilityPacket.useAbility(player, true); diff --git a/src/main/java/dev/mrsterner/besmirchment/common/entity/WerepyreEntity.java b/src/main/java/dev/mrsterner/besmirchment/common/entity/WerepyreEntity.java index ff6c7a4..0a31da6 100644 --- a/src/main/java/dev/mrsterner/besmirchment/common/entity/WerepyreEntity.java +++ b/src/main/java/dev/mrsterner/besmirchment/common/entity/WerepyreEntity.java @@ -3,6 +3,7 @@ import dev.mrsterner.besmirchment.common.entity.interfaces.VillagerWerepyreAccessor; import moriyashiine.bewitchment.api.BewitchmentAPI; import moriyashiine.bewitchment.client.packet.SpawnSmokeParticlesPacket; +import moriyashiine.bewitchment.common.entity.living.WerewolfEntity; import moriyashiine.bewitchment.common.entity.living.util.BWHostileEntity; import moriyashiine.bewitchment.common.registry.BWComponents; import moriyashiine.bewitchment.common.registry.BWSoundEvents; @@ -51,7 +52,9 @@ public void tick() { if (storedVillager != null && age % 20 == 0 && (getWorld().isDay() || BewitchmentAPI.getMoonPhase(getWorld()) != 0)) { VillagerEntity entity = EntityType.VILLAGER.create(getWorld()); if (entity instanceof VillagerWerepyreAccessor) { - PlayerLookup.tracking(this).forEach(player -> SpawnSmokeParticlesPacket.send(player, this)); + if (!getWorld().isClient) { + PlayerLookup.tracking(this).forEach(player -> SpawnSmokeParticlesPacket.send(player, this)); + } getWorld().playSound(null, getX(), getY(), getZ(), BWSoundEvents.ENTITY_GENERIC_TRANSFORM, getSoundCategory(), getSoundVolume(), getSoundPitch()); entity.readNbt(storedVillager); entity.updatePositionAndAngles(getX(), getY(), getZ(), random.nextFloat() * 360, 0); diff --git a/src/main/java/dev/mrsterner/besmirchment/mixin/LivingEntityMixin.java b/src/main/java/dev/mrsterner/besmirchment/mixin/LivingEntityMixin.java index b2f7c15..b2ea2ef 100644 --- a/src/main/java/dev/mrsterner/besmirchment/mixin/LivingEntityMixin.java +++ b/src/main/java/dev/mrsterner/besmirchment/mixin/LivingEntityMixin.java @@ -39,6 +39,7 @@ import net.minecraft.nbt.NbtCompound; import net.minecraft.particle.DustParticleEffect; import net.minecraft.registry.tag.DamageTypeTags; +import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; import net.minecraft.util.Hand; import net.minecraft.util.Pair; @@ -205,8 +206,11 @@ private void tryUseTotem(DamageSource source, CallbackInfoReturnable ci transformationComponent.getTransformation().onRemoved(playerEntity); transformationComponent.setTransformation(BSMTransformations.WEREPYRE); transformationComponent.getTransformation().onAdded(playerEntity); - PlayerLookup.tracking(playerEntity).forEach(foundPlayer -> SpawnSmokeParticlesPacket.send(foundPlayer, playerEntity)); - SpawnSmokeParticlesPacket.send(playerEntity, playerEntity); + if (playerEntity instanceof ServerPlayerEntity serverPlayerEntity) { + PlayerLookup.tracking(playerEntity).forEach(foundPlayer -> SpawnSmokeParticlesPacket.send(foundPlayer, playerEntity)); + SpawnSmokeParticlesPacket.send(serverPlayerEntity, playerEntity); + } + playerEntity.getWorld().playSound(null, playerEntity.getBlockPos(), BWSoundEvents.ENTITY_GENERIC_CURSE, playerEntity.getSoundCategory(), 1, 1); int variant = -1; if (source.getSource() instanceof WerepyreEntity) { diff --git a/src/main/java/dev/mrsterner/besmirchment/mixin/TransformationAbilityPacketMixin.java b/src/main/java/dev/mrsterner/besmirchment/mixin/TransformationAbilityPacketMixin.java index e6f1258..db8829d 100644 --- a/src/main/java/dev/mrsterner/besmirchment/mixin/TransformationAbilityPacketMixin.java +++ b/src/main/java/dev/mrsterner/besmirchment/mixin/TransformationAbilityPacketMixin.java @@ -14,6 +14,7 @@ import net.minecraft.entity.EntityType; import net.minecraft.entity.effect.StatusEffects; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -59,8 +60,10 @@ private static void useAbility(PlayerEntity player, boolean forced, CallbackInfo boolean isInAlternateForm = BWComponents.TRANSFORMATION_COMPONENT.get(player).isAlternateForm(); ScaleData width = BWScaleTypes.MODIFY_WIDTH_TYPE.getScaleData(player); ScaleData height = BWScaleTypes.MODIFY_HEIGHT_TYPE.getScaleData(player); - PlayerLookup.tracking(player).forEach((foundPlayer) -> SpawnSmokeParticlesPacket.send(foundPlayer, player)); - SpawnSmokeParticlesPacket.send(player, player); + if (player instanceof ServerPlayerEntity serverPlayerEntity) { + PlayerLookup.tracking(player).forEach(foundPlayer -> SpawnSmokeParticlesPacket.send(foundPlayer, player)); + SpawnSmokeParticlesPacket.send(serverPlayerEntity, player); + } world.playSound(null, player.getBlockPos(), BWSoundEvents.ENTITY_GENERIC_TRANSFORM, player.getSoundCategory(), 1.0F, 1.0F); BWComponents.TRANSFORMATION_COMPONENT.get(player).setAlternateForm(!isInAlternateForm); if (isInAlternateForm) {