Skip to content

Commit

Permalink
Spawning
Browse files Browse the repository at this point in the history
  • Loading branch information
N1nn1 committed May 6, 2024
1 parent 143b520 commit 377ab16
Show file tree
Hide file tree
Showing 18 changed files with 44 additions and 43 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/ninni/spawn/block/MucusBlockBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


import com.ninni.spawn.SpawnProperties;
import com.ninni.spawn.SpawnTags;
import com.ninni.spawn.registry.SpawnTags;
import com.ninni.spawn.registry.SpawnCriteriaTriggers;
import com.ninni.spawn.registry.SpawnEntityType;
import net.minecraft.core.BlockPos;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.ninni.spawn.client.inventory;

import com.ninni.spawn.SpawnTags;
import com.ninni.spawn.registry.SpawnTags;
import com.ninni.spawn.entity.Seahorse;
import com.ninni.spawn.mixin.accessor.TropicalFishAccessor;
import com.ninni.spawn.registry.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.google.common.collect.Lists;
import com.mojang.blaze3d.systems.RenderSystem;
import com.ninni.spawn.Spawn;
import com.ninni.spawn.SpawnTags;
import com.ninni.spawn.registry.SpawnTags;
import com.ninni.spawn.entity.Seahorse;
import com.ninni.spawn.mixin.accessor.TropicalFishAccessor;
import com.ninni.spawn.registry.SpawnEntityType;
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/ninni/spawn/client/model/SunfishModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,14 @@ public void setupAnim(Sunfish entity, float limbSwing, float limbSwingAmount, fl
this.bottomFin.zRot = 0;

if (entity.isInWaterOrBubble()) {
this.animateWalk(SunfishAnimation.SWIM, limbSwing, limbSwingAmount, 1.5f, 8.0f);
this.animateWalk(SunfishAnimation.SWIM, limbSwing, limbSwingAmount, 2.5f, 8.0f);
this.animate(entity.idleAnimationState, SunfishAnimation.IDLE, animationProgress, 1.0f);
this.animate(entity.flopAnimationState, SunfishAnimation.FLOP, animationProgress, 1.0f);
}
else this.animate(entity.landAnimationState, SunfishAnimation.LAND, animationProgress, 1.0f);
} else {
this.all.zRot = pi/2;
if (!entity.isInWaterOrBubble()) this.all.zRot = pi/2;
else this.all.zRot = 0;
this.all.y = Mth.cos(animationProgress * 0.2F) * 1.5F * 0.25F + (entity.getSunfishAge() == -2 ? 22.5F : 19.0F);
this.all.yRot = Mth.cos(animationProgress * 0.2F) * 0.4F * 0.25F;
this.tailFin.yRot = Mth.cos(animationProgress * 0.4F) * 0.8F * 0.25F;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/ninni/spawn/entity/AnglerFish.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.ninni.spawn.entity;


import com.ninni.spawn.SpawnTags;
import com.ninni.spawn.registry.SpawnTags;
import com.ninni.spawn.entity.common.DeepLurker;
import com.ninni.spawn.entity.common.FlopConditionable;
import com.ninni.spawn.registry.SpawnCriteriaTriggers;
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/com/ninni/spawn/entity/Ant.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.ninni.spawn.entity;

import com.google.common.collect.Lists;
import com.ninni.spawn.SpawnTags;
import com.ninni.spawn.registry.SpawnTags;
import com.ninni.spawn.block.entity.AnthillBlockEntity;
import com.ninni.spawn.registry.SpawnBlockEntityTypes;
import com.ninni.spawn.registry.SpawnSoundEvents;
Expand Down Expand Up @@ -39,7 +39,6 @@
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.ai.control.LookControl;
import net.minecraft.world.entity.ai.goal.BreedGoal;
import net.minecraft.world.entity.ai.goal.FloatGoal;
import net.minecraft.world.entity.ai.goal.FollowOwnerGoal;
import net.minecraft.world.entity.ai.goal.Goal;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/ninni/spawn/entity/Hamster.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.ninni.spawn.entity;

import com.ninni.spawn.SpawnTags;
import com.ninni.spawn.registry.SpawnTags;
import com.ninni.spawn.entity.variant.HamsterVariant;
import com.ninni.spawn.registry.SpawnCriteriaTriggers;
import com.ninni.spawn.registry.SpawnEntityType;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/ninni/spawn/entity/SeaCow.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.ninni.spawn.entity;

import com.ninni.spawn.SpawnTags;
import com.ninni.spawn.registry.SpawnTags;
import com.ninni.spawn.entity.ai.goal.EatSeagrassGoal;
import com.ninni.spawn.entity.common.DeepLurker;
import com.ninni.spawn.registry.SpawnBlocks;
Expand Down
10 changes: 1 addition & 9 deletions src/main/java/com/ninni/spawn/entity/Snail.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package com.ninni.spawn.entity;

import com.google.common.collect.Lists;
import com.ninni.spawn.SpawnTags;
import com.ninni.spawn.registry.SpawnTags;
import com.ninni.spawn.block.SnailEggsBlock;
import com.ninni.spawn.registry.SpawnBlocks;
import com.ninni.spawn.registry.SpawnCriteriaTriggers;
import com.ninni.spawn.registry.SpawnItems;
import com.ninni.spawn.registry.SpawnSoundEvents;
import net.minecraft.ChatFormatting;
import net.minecraft.advancements.CriteriaTriggers;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
Expand All @@ -29,20 +27,14 @@
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.*;
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.ai.goal.*;
import net.minecraft.world.entity.animal.Animal;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.projectile.Projectile;
import net.minecraft.world.entity.projectile.ThrownPotion;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.alchemy.Potion;
import net.minecraft.world.item.alchemy.PotionUtils;
import net.minecraft.world.item.alchemy.Potions;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.level.GameRules;
import net.minecraft.world.level.Level;
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/com/ninni/spawn/entity/Sunfish.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.ninni.spawn.entity;

import com.ninni.spawn.SpawnTags;
import com.ninni.spawn.registry.SpawnTags;
import com.ninni.spawn.registry.SpawnItems;
import com.ninni.spawn.registry.SpawnPose;
import com.ninni.spawn.registry.SpawnSoundEvents;
Expand Down Expand Up @@ -87,7 +87,8 @@ public SpawnGroupData finalizeSpawn(ServerLevelAccessor serverLevelAccessor, Dif
if (mobSpawnType == MobSpawnType.BUCKET) {
return spawnGroupData;
} else {
this.setVariant(Util.getRandom(Variant.values(), this.random));
int i = serverLevelAccessor.getBiome(blockPosition()).is(SpawnTags.SUNFISH_WARM_VARIANT) ? random.nextInt(0,2) : random.nextInt(2, 4);
this.setVariant(Variant.byId(i));
return super.finalizeSpawn(serverLevelAccessor, difficultyInstance, mobSpawnType, spawnGroupData, compoundTag);
}
}
Expand Down Expand Up @@ -365,8 +366,8 @@ public Variant getVariant() {

public enum Variant implements StringRepresentable {
PLAIN(0, "plain"),
PLAIN_DARK(1, "plain_dark"),
STRIPED(2, "striped"),
STRIPED(1, "striped"),
PLAIN_DARK(2, "plain_dark"),
STRIPED_DARK(3, "striped_dark");

private static final IntFunction<Variant> BY_ID = ByIdMap.sparse(Variant::getId, Variant.values(), PLAIN);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/ninni/spawn/entity/Tuna.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.ninni.spawn.entity;

import com.ninni.spawn.SpawnTags;
import com.ninni.spawn.registry.SpawnTags;
import com.ninni.spawn.entity.ai.goal.WaterJumpGoal;
import com.ninni.spawn.registry.SpawnEntityType;
import com.ninni.spawn.registry.SpawnSoundEvents;
Expand Down
8 changes: 1 addition & 7 deletions src/main/java/com/ninni/spawn/entity/Whale.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
package com.ninni.spawn.entity;

import com.ninni.spawn.SpawnTags;
import com.ninni.spawn.registry.SpawnTags;
import com.ninni.spawn.registry.SpawnEntityType;
import com.ninni.spawn.registry.SpawnSoundEvents;
import net.minecraft.core.BlockPos;
import net.minecraft.network.protocol.game.ClientboundAddEntityPacket;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.tags.DamageTypeTags;
import net.minecraft.tags.FluidTags;
import net.minecraft.util.Mth;
import net.minecraft.util.RandomSource;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.*;
Expand All @@ -23,9 +20,6 @@
import net.minecraft.world.entity.ai.navigation.WaterBoundPathNavigation;
import net.minecraft.world.entity.ai.util.DefaultRandomPos;
import net.minecraft.world.entity.animal.Animal;
import net.minecraft.world.entity.boss.EnderDragonPart;
import net.minecraft.world.entity.boss.enderdragon.phases.EnderDragonPhase;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/ninni/spawn/item/ClamCaseItem.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.ninni.spawn.item;

import com.ninni.spawn.SpawnTags;
import com.ninni.spawn.registry.SpawnTags;
import net.minecraft.ChatFormatting;
import net.minecraft.core.NonNullList;
import net.minecraft.nbt.CompoundTag;
Expand Down
19 changes: 10 additions & 9 deletions src/main/java/com/ninni/spawn/registry/SpawnEntityType.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.ninni.spawn.registry;

import com.ninni.spawn.Spawn;
import com.ninni.spawn.SpawnTags;
import com.ninni.spawn.entity.*;
import net.fabricmc.fabric.api.biome.v1.BiomeModifications;
import net.fabricmc.fabric.api.biome.v1.BiomeSelectors;
Expand Down Expand Up @@ -181,14 +180,16 @@ public class SpawnCephalopod {
}
static {
BiomeModifications.addSpawn(BiomeSelectors.tag(SpawnTags.CLAM_SPAWNS), MobCategory.WATER_AMBIENT, SpawnAquaticCreature.CLAM, 150, 4, 12);
BiomeModifications.addSpawn(BiomeSelectors.tag(SpawnTags.ANGLER_FISH_SPAWNS), MobCategory.WATER_AMBIENT, SpawnEntityType.SpawnFish.ANGLER_FISH, 5, 1, 1);
BiomeModifications.addSpawn(BiomeSelectors.tag(SpawnTags.TUNA_SPAWNS), MobCategory.WATER_CREATURE, SpawnEntityType.SpawnFish.TUNA, 15, 1, 3);
BiomeModifications.addSpawn(BiomeSelectors.tag(SpawnTags.HERRING_SPAWNS), MobCategory.WATER_AMBIENT, SpawnEntityType.SpawnFish.HERRING, 15, 4, 12);
BiomeModifications.addSpawn(BiomeSelectors.tag(SpawnTags.SEA_COW_SPAWNS), MobCategory.WATER_CREATURE, SpawnEntityType.SpawnAquaticCreature.SEA_COW, 20, 1, 3);
BiomeModifications.addSpawn(BiomeSelectors.tag(SpawnTags.SEAHORSE_SPAWNS), MobCategory.WATER_AMBIENT, SpawnEntityType.SpawnFish.SEAHORSE, 20, 1, 3);
BiomeModifications.addSpawn(BiomeSelectors.tag(SpawnTags.SNAIL_SPAWNS), MobCategory.CREATURE, SpawnEntityType.SpawnLandCreature.SNAIL, 12, 1, 3);
BiomeModifications.addSpawn(BiomeSelectors.tag(SpawnTags.HAMSTER_SPAWNS), MobCategory.CREATURE, SpawnEntityType.SpawnLandCreature.HAMSTER, 25, 1, 1);
BiomeModifications.addSpawn(BiomeSelectors.tag(SpawnTags.HAMSTER_FREQUENTLY_SPAWNS), MobCategory.CREATURE, SpawnEntityType.SpawnLandCreature.HAMSTER, 50, 1, 4);
BiomeModifications.addSpawn(BiomeSelectors.tag(SpawnTags.ANGLER_FISH_SPAWNS), MobCategory.WATER_AMBIENT, SpawnFish.ANGLER_FISH, 5, 1, 1);
BiomeModifications.addSpawn(BiomeSelectors.tag(SpawnTags.TUNA_SPAWNS), MobCategory.WATER_CREATURE, SpawnFish.TUNA, 15, 1, 3);
BiomeModifications.addSpawn(BiomeSelectors.tag(SpawnTags.HERRING_SPAWNS), MobCategory.WATER_AMBIENT, SpawnFish.HERRING, 15, 4, 12);
BiomeModifications.addSpawn(BiomeSelectors.tag(SpawnTags.SEA_COW_SPAWNS), MobCategory.WATER_CREATURE, SpawnAquaticCreature.SEA_COW, 20, 1, 3);
BiomeModifications.addSpawn(BiomeSelectors.tag(SpawnTags.SEAHORSE_SPAWNS), MobCategory.WATER_AMBIENT, SpawnFish.SEAHORSE, 20, 1, 3);
BiomeModifications.addSpawn(BiomeSelectors.tag(SpawnTags.SNAIL_SPAWNS), MobCategory.CREATURE, SpawnLandCreature.SNAIL, 12, 1, 3);
BiomeModifications.addSpawn(BiomeSelectors.tag(SpawnTags.HAMSTER_SPAWNS), MobCategory.CREATURE, SpawnLandCreature.HAMSTER, 25, 1, 1);
BiomeModifications.addSpawn(BiomeSelectors.tag(SpawnTags.HAMSTER_FREQUENTLY_SPAWNS), MobCategory.CREATURE, SpawnLandCreature.HAMSTER, 50, 1, 4);
BiomeModifications.addSpawn(BiomeSelectors.tag(SpawnTags.SUNFISH_WARM_VARIANT), MobCategory.WATER_CREATURE, SpawnFish.SUNFISH, 20, 1, 2);
BiomeModifications.addSpawn(BiomeSelectors.tag(SpawnTags.SUNFISH_COLD_VARIANT), MobCategory.WATER_CREATURE, SpawnFish.SUNFISH, 20, 1, 2);
}

private static <T extends Entity> EntityType<T> register(String id, FabricEntityTypeBuilder<T> entityType) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.ninni.spawn;
package com.ninni.spawn.registry;

import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
Expand Down Expand Up @@ -51,6 +51,8 @@ public interface SpawnTags {
TagKey<Biome> HAMSTER_FREQUENTLY_SPAWNS = TagKey.create(Registries.BIOME, new ResourceLocation(MOD_ID, "hamster_frequently_spawns"));
TagKey<Biome> HAMSTER_SPAWNS = TagKey.create(Registries.BIOME, new ResourceLocation(MOD_ID, "hamster_spawns"));
TagKey<Biome> SEA_COW_SPAWNS = TagKey.create(Registries.BIOME, new ResourceLocation(MOD_ID, "sea_cow_spawns"));
TagKey<Biome> SUNFISH_WARM_VARIANT = TagKey.create(Registries.BIOME, new ResourceLocation(MOD_ID, "sunfish_warm_variant"));
TagKey<Biome> SUNFISH_COLD_VARIANT = TagKey.create(Registries.BIOME, new ResourceLocation(MOD_ID, "sunfish_cold_variant"));
TagKey<Biome> SMALL_ANTHILL_GENERATES = TagKey.create(Registries.BIOME, new ResourceLocation(MOD_ID, "small_anthill_generates"));

//pointOfInterest tags
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.ninni.spawn.registry;

import com.google.common.reflect.Reflection;
import com.ninni.spawn.SpawnTags;
import com.ninni.spawn.client.inventory.PigmentShifterScreen;
import com.ninni.spawn.client.inventory.HamsterInventoryMenu;
import com.ninni.spawn.client.inventory.HamsterInventoryScreen;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"values": [
"minecraft:cold_ocean",
"minecraft:deep_cold_ocean"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"values": [
"minecraft:lukewarm_ocean",
"minecraft:deep_lukewarm_ocean"
]
}

0 comments on commit 377ab16

Please sign in to comment.