Fish spawning

This commit is contained in:
paulevsGitch 2020-10-24 00:25:37 +03:00
parent ad59f5b80d
commit 6e202c2452
5 changed files with 19 additions and 1 deletions

View file

@ -1,8 +1,11 @@
package ru.betterend.entity;
import java.util.Random;
import net.minecraft.block.Blocks;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.SpawnReason;
import net.minecraft.entity.attribute.DefaultAttributeContainer;
import net.minecraft.entity.attribute.EntityAttributes;
import net.minecraft.entity.damage.DamageSource;
@ -15,6 +18,8 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.sound.SoundEvent;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.ServerWorldAccess;
import net.minecraft.world.World;
public class EntityEndFish extends SchoolingFishEntity {
@ -101,4 +106,8 @@ public class EntityEndFish extends SchoolingFishEntity {
public float getScale() {
return this.dataTracker.get(SCALE) / 32F + 0.75F;
}
public static boolean canSpawn(EntityType<EntityEndFish> type, ServerWorldAccess world, SpawnReason spawnReason, BlockPos pos, Random random) {
return true;
}
}

View file

@ -24,6 +24,7 @@ public class EntityRegistry {
public static void register() {
SpawnHelper.restrictionLand(END_SLIME, EntityEndSlime::canSpawn);
SpawnHelper.restrictionWater(END_FISH, EntityEndFish::canSpawn);
}
protected static <T extends Entity> EntityType<T> register(String name, SpawnGroup group, float width, float height, EntityFactory<T> entity) {

View file

@ -32,6 +32,10 @@ public class SpawnHelper {
restriction(entity, Location.ON_GROUND, Type.MOTION_BLOCKING, predicate);
}
public static <T extends MobEntity> void restrictionWater(EntityType<T> entity, SpawnPredicate<T> predicate) {
restriction(entity, Location.IN_WATER, Type.MOTION_BLOCKING, predicate);
}
static {
try {
for (Method method: SpawnRestriction.class.getDeclaredMethods()) {

View file

@ -31,6 +31,7 @@ public class BiomeFoggyMushroomland extends EndBiome {
.addFeature(FeatureRegistry.BUBBLE_CORAL)
.addStructureFeature(ConfiguredStructureFeatures.END_CITY)
.addMobSpawn(EntityRegistry.DRAGONFLY, 80, 2, 5)
.addMobSpawn(EntityRegistry.END_FISH, 20, 2, 5)
.addMobSpawn(EntityRegistry.END_SLIME, 10, 1, 2)
.addMobSpawn(EntityType.ENDERMAN, 10, 1, 2));
}

View file

@ -3,6 +3,7 @@ package ru.betterend.world.biome;
import net.minecraft.entity.EntityType;
import net.minecraft.world.gen.feature.ConfiguredStructureFeatures;
import ru.betterend.registry.BlockRegistry;
import ru.betterend.registry.EntityRegistry;
import ru.betterend.registry.FeatureRegistry;
import ru.betterend.registry.StructureRegistry;
@ -20,6 +21,8 @@ public class BiomeMegalake extends EndBiome {
.addFeature(FeatureRegistry.END_LOTUS_LEAF)
.addFeature(FeatureRegistry.BUBBLE_CORAL_RARE)
.addFeature(FeatureRegistry.END_LILY_RARE)
.addMobSpawn(EntityType.ENDERMAN, 50, 1, 2));
.addMobSpawn(EntityRegistry.DRAGONFLY, 50, 1, 3)
.addMobSpawn(EntityRegistry.END_FISH, 50, 3, 8)
.addMobSpawn(EntityType.ENDERMAN, 10, 1, 2));
}
}