Skip to content

Commit

Permalink
BugFixing
Browse files Browse the repository at this point in the history
  • Loading branch information
N1nn1 committed May 8, 2024
1 parent 6ae248d commit d2c6c49
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 31 deletions.
20 changes: 13 additions & 7 deletions src/main/java/com/ninni/spawn/client/model/SunfishModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/ninni/spawn/entity/Herring.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ public int getSchoolSize() {
}


@Override
public int getMaxSpawnClusterSize() {
return 20;
}


@Override
public int getMaxSchoolSize() {
return this.getSchoolSize();
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/ninni/spawn/entity/Sunfish.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
25 changes: 3 additions & 22 deletions src/main/java/com/ninni/spawn/entity/common/BoidFishEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public abstract class BoidFishEntity extends AbstractFish {
public BoidFishEntity leader;
public List<BoidFishEntity> ownSchool = new ArrayList<>();
private int maxSchoolSize;
public int cantSwimTimer = 40;
public int cantFollowTimer;

public BoidFishEntity(EntityType<? extends AbstractFish> entityType, Level level) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;

Expand All @@ -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();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "spawn:item/baby_sunfish_bucket"
"layer0": "spawn:item/newborn_sunfish_bucket"
},
"overrides": [
{
Expand Down

0 comments on commit d2c6c49

Please sign in to comment.