From d2c6c4914e5399954a9dd06e43b948a3fc77042f Mon Sep 17 00:00:00 2001 From: N1nn1 <64173061+N1nn1@users.noreply.github.com> Date: Wed, 8 May 2024 15:47:26 +0200 Subject: [PATCH] BugFixing --- .../spawn/client/model/SunfishModel.java | 20 +++++++++------ .../java/com/ninni/spawn/entity/Herring.java | 6 +++++ .../java/com/ninni/spawn/entity/Sunfish.java | 1 + .../spawn/entity/common/BoidFishEntity.java | 25 +++---------------- .../registry/SpawnVanillaIntegration.java | 2 +- .../models/item/baby_sunfish_bucket.json | 2 +- 6 files changed, 25 insertions(+), 31 deletions(-) diff --git a/src/main/java/com/ninni/spawn/client/model/SunfishModel.java b/src/main/java/com/ninni/spawn/client/model/SunfishModel.java index 794f18f..8dcb975 100644 --- a/src/main/java/com/ninni/spawn/client/model/SunfishModel.java +++ b/src/main/java/com/ninni/spawn/client/model/SunfishModel.java @@ -58,18 +58,24 @@ public void setupAnim(Sunfish entity, float limbSwing, float limbSwingAmount, fl } else this.animate(entity.landAnimationState, SunfishAnimation.LAND, animationProgress, 1.0f); } else { - if (!entity.isInWaterOrBubble()) this.all.zRot = pi/2; - else this.all.zRot = 0; - this.all.y = Mth.sin(animationProgress * 0.2F) * 1.5F * 0.5F + (entity.getSunfishAge() == -2 ? 22.5F : 19.0F); - this.all.yRot = Mth.cos(animationProgress * 0.2F) * 0.4F * 0.25F; + if (!entity.isInWaterOrBubble()) { + this.all.y = (entity.getSunfishAge() == -2 ? 22.5F : 22.0F); + this.all.zRot = pi/2; + this.all.xRot = 0; + this.all.yRot = 0; + } + else { + this.all.zRot = 0; + this.all.xRot = headPitch * (float) (Math.PI / 180); + this.all.yRot = headYaw * (float) (Math.PI / 180); + } + this.all.y += Mth.sin(animationProgress * 0.2F) * 1.5F * 0.5F; + this.all.yRot += Mth.cos(animationProgress * 0.2F) * 0.4F * 0.25F; this.tailFin.yRot = Mth.cos(animationProgress * 0.4F) * 0.8F * 0.25F; this.leftFin.yRot = Mth.cos(animationProgress * 0.4F) * 0.8F * 0.25F + 0.8F; this.rightFin.yRot = Mth.cos(animationProgress * 0.4F + pi) * 0.8F * 0.25F - 0.8F; this.topFin.zRot = Mth.cos(animationProgress * 0.4F) * 1.6F * 0.25F; this.bottomFin.zRot = Mth.cos(animationProgress * 0.4F + pi) * 1.6F * 0.25F; - - this.all.xRot += headPitch * (float) (Math.PI / 180); - this.all.yRot += headYaw * (float) (Math.PI / 180); } } diff --git a/src/main/java/com/ninni/spawn/entity/Herring.java b/src/main/java/com/ninni/spawn/entity/Herring.java index 3bc6473..4195db5 100644 --- a/src/main/java/com/ninni/spawn/entity/Herring.java +++ b/src/main/java/com/ninni/spawn/entity/Herring.java @@ -82,6 +82,12 @@ public int getSchoolSize() { } + @Override + public int getMaxSpawnClusterSize() { + return 20; + } + + @Override public int getMaxSchoolSize() { return this.getSchoolSize(); diff --git a/src/main/java/com/ninni/spawn/entity/Sunfish.java b/src/main/java/com/ninni/spawn/entity/Sunfish.java index ce06f45..28e7cd6 100644 --- a/src/main/java/com/ninni/spawn/entity/Sunfish.java +++ b/src/main/java/com/ninni/spawn/entity/Sunfish.java @@ -463,6 +463,7 @@ public void saveToBucketTag(ItemStack itemStack) { @Override public void loadFromBucketTag(CompoundTag compoundTag) { if (compoundTag.contains("Age")) this.setAge(compoundTag.getInt("Age")); + else this.setAge(-48000); if (compoundTag.contains("Variant")) this.setVariant(Variant.byId(compoundTag.getInt("Variant"))); Bucketable.loadDefaultDataFromBucketTag(this, compoundTag); } diff --git a/src/main/java/com/ninni/spawn/entity/common/BoidFishEntity.java b/src/main/java/com/ninni/spawn/entity/common/BoidFishEntity.java index f474d3f..5648036 100644 --- a/src/main/java/com/ninni/spawn/entity/common/BoidFishEntity.java +++ b/src/main/java/com/ninni/spawn/entity/common/BoidFishEntity.java @@ -26,6 +26,7 @@ public abstract class BoidFishEntity extends AbstractFish { public BoidFishEntity leader; public List ownSchool = new ArrayList<>(); private int maxSchoolSize; + public int cantSwimTimer = 40; public int cantFollowTimer; public BoidFishEntity(EntityType entityType, Level level) { @@ -73,6 +74,7 @@ protected SoundEvent getSwimSound() { private void addToOwnSchoolFollower(BoidFishEntity entity) { if (entity.cantFollowTimer == 0) this.ownSchool.add(entity); + if (entity.cantSwimTimer > 0) this.cantSwimTimer--; } private void removeFollowerFromOwnSchool(BoidFishEntity entity) { @@ -104,27 +106,6 @@ public boolean inRangeOfLeader() { return this.distanceToSqr(this.leader) <= 200.0; } - @Override - @Nullable - public SpawnGroupData finalizeSpawn(ServerLevelAccessor serverLevelAccessor, DifficultyInstance difficultyInstance, MobSpawnType mobSpawnType, @Nullable SpawnGroupData spawnGroupData, @Nullable CompoundTag compoundTag) { - super.finalizeSpawn(serverLevelAccessor, difficultyInstance, mobSpawnType, spawnGroupData, compoundTag); - if (spawnGroupData == null) { - spawnGroupData = new BoidFishEntity.SchoolSpawnGroupData(this); - } else { - this.startFollowing(((BoidFishEntity.SchoolSpawnGroupData)spawnGroupData).leader); - } - return spawnGroupData; - } - - public static class SchoolSpawnGroupData - implements SpawnGroupData { - public final BoidFishEntity leader; - - public SchoolSpawnGroupData(BoidFishEntity boidFish) { - this.leader = boidFish; - } - } - static class FishSwimGoal extends RandomSwimmingGoal { private final BoidFishEntity fish; @@ -135,7 +116,7 @@ public FishSwimGoal(BoidFishEntity boidFish) { @Override public boolean canUse() { - return !this.fish.isFollower() && !this.fish.hasFollowers() && super.canUse(); + return !this.fish.isFollower() && !this.fish.hasFollowers() && fish.cantSwimTimer == 0 && super.canUse(); } } } diff --git a/src/main/java/com/ninni/spawn/registry/SpawnVanillaIntegration.java b/src/main/java/com/ninni/spawn/registry/SpawnVanillaIntegration.java index cbfed48..5204019 100644 --- a/src/main/java/com/ninni/spawn/registry/SpawnVanillaIntegration.java +++ b/src/main/java/com/ninni/spawn/registry/SpawnVanillaIntegration.java @@ -174,7 +174,7 @@ private static void registerItemModelPredicates() { if (a < -24000) return 0f; else return 1f; } - return 1f; + return 0f; }); ItemProperties.register(SpawnItems.CLAM_CASE, new ResourceLocation("filled"), (itemStack, clientLevel, livingEntity, i) -> ClamCaseItem.getFullnessDisplay(itemStack)); diff --git a/src/main/resources/assets/spawn/models/item/baby_sunfish_bucket.json b/src/main/resources/assets/spawn/models/item/baby_sunfish_bucket.json index f9419b7..25fe3a0 100644 --- a/src/main/resources/assets/spawn/models/item/baby_sunfish_bucket.json +++ b/src/main/resources/assets/spawn/models/item/baby_sunfish_bucket.json @@ -1,7 +1,7 @@ { "parent": "minecraft:item/generated", "textures": { - "layer0": "spawn:item/baby_sunfish_bucket" + "layer0": "spawn:item/newborn_sunfish_bucket" }, "overrides": [ {