Some entity refactoring

This commit is contained in:
Sollace 2020-09-22 12:28:44 +02:00
parent 00f677c157
commit 94eef4f43a
5 changed files with 24 additions and 26 deletions

View file

@ -7,8 +7,8 @@ import net.minecraft.world.gen.feature.StructureFeature;
@Mixin(StructureFeature.class)
public interface MixinStructureFeature {
@Invoker
@Invoker("register")
static <F extends StructureFeature<?>> F register(String name, F structureFeature, GenerationStep.Feature step) {
return null;
throw new NullPointerException("mixin y u fail");
}
}

View file

@ -25,12 +25,9 @@ import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.biome.Biome.SpawnEntry;
public class ButterflyEntity extends AmbientEntity {
public static final SpawnEntry SPAWN_ENTRY = new SpawnEntry(UEntities.BUTTERFLY, 15, 9, 15);
private static final TrackedData<Boolean> RESTING = DataTracker.registerData(ButterflyEntity.class, TrackedDataHandlerRegistry.BOOLEAN);
private static final TrackedData<Integer> VARIANT = DataTracker.registerData(ButterflyEntity.class, TrackedDataHandlerRegistry.INTEGER);

View file

@ -18,12 +18,9 @@ import net.minecraft.util.math.Box;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.biome.Biome.SpawnEntry;
public class RainbowEntity extends MobEntity implements InAnimate {
public static final SpawnEntry SPAWN_ENTRY = new SpawnEntry(UEntities.RAINBOW, 1, 1, 1);
private int ticksAlive;
private final double radius;

View file

@ -4,6 +4,7 @@ import java.util.List;
import net.fabricmc.fabric.api.object.builder.v1.entity.FabricDefaultAttributeRegistry;
import net.fabricmc.fabric.api.object.builder.v1.entity.FabricEntityTypeBuilder;
import net.fabricmc.fabric.impl.biome.InternalBiomeData;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityDimensions;
import net.minecraft.entity.EntityType;
@ -12,13 +13,9 @@ import net.minecraft.entity.SpawnGroup;
import net.minecraft.entity.attribute.DefaultAttributeContainer;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.biome.EndBiome;
import net.minecraft.world.biome.ForestBiome;
import net.minecraft.world.biome.MountainsBiome;
import net.minecraft.world.biome.NetherWastesBiome;
import net.minecraft.world.biome.OceanBiome;
import net.minecraft.world.biome.PlainsBiome;
import net.minecraft.world.biome.RiverBiome;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.Biome.SpawnEntry;
public interface UEntities {
EntityType<SpellbookEntity> SPELLBOOK = register("spellbook", FabricEntityTypeBuilder.create(SpawnGroup.MISC, SpellbookEntity::new)
@ -71,17 +68,26 @@ public interface UEntities {
}
static void bootstrap() {
final SpawnEntry CLOUD_SPAWN_ENTRY_LAND = new SpawnEntry(WILD_CLOUD, 1, 1, 15);
final SpawnEntry CLOUD_SPAWN_ENTRY_OCEAN = new SpawnEntry(WILD_CLOUD, 1, 1, 7);
final SpawnEntry BUTTERFLY_SPAWN_ENTRY = new SpawnEntry(BUTTERFLY, 15, 9, 15);
final SpawnEntry RAINBOW_SPAWN_ENTRY = new SpawnEntry(RAINBOW, 1, 1, 1);
Registry.BIOME.forEach(biome -> {
if (!(biome instanceof NetherWastesBiome || biome instanceof EndBiome)) {
addifAbsent(biome.getEntitySpawnList(SpawnGroup.AMBIENT), biome instanceof OceanBiome ? WildCloudEntity.SPAWN_ENTRY_OCEAN : WildCloudEntity.SPAWN_ENTRY_LAND);
addifAbsent(biome.getEntitySpawnList(SpawnGroup.CREATURE), RainbowEntity.SPAWN_ENTRY);
Biome.Category category = biome.getCategory();
boolean isNether = category == Biome.Category.NETHER || InternalBiomeData.getNetherBiomes().contains(biome);
if (!isNether && category != Biome.Category.THEEND) {
addifAbsent(biome.getEntitySpawnList(SpawnGroup.AMBIENT), biome instanceof OceanBiome ? CLOUD_SPAWN_ENTRY_OCEAN : CLOUD_SPAWN_ENTRY_LAND);
addifAbsent(biome.getEntitySpawnList(SpawnGroup.CREATURE), RAINBOW_SPAWN_ENTRY);
}
if (biome instanceof PlainsBiome
|| biome instanceof RiverBiome
|| biome instanceof MountainsBiome
|| biome instanceof ForestBiome) {
addifAbsent(biome.getEntitySpawnList(SpawnGroup.AMBIENT), ButterflyEntity.SPAWN_ENTRY);
if (category == Biome.Category.PLAINS
|| category == Biome.Category.RIVER
|| category == Biome.Category.FOREST
|| category == Biome.Category.EXTREME_HILLS) {
addifAbsent(biome.getEntitySpawnList(SpawnGroup.AMBIENT), BUTTERFLY_SPAWN_ENTRY);
}
});
}
@ -91,4 +97,6 @@ public interface UEntities {
entries.add(entry);
}
}
}

View file

@ -16,14 +16,10 @@ import net.minecraft.util.math.Vec3d;
import net.minecraft.world.LocalDifficulty;
import net.minecraft.world.World;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.biome.Biome.SpawnEntry;
import net.minecraft.world.chunk.WorldChunk;
public class WildCloudEntity extends CloudEntity {
public static final SpawnEntry SPAWN_ENTRY_LAND = new SpawnEntry(UEntities.WILD_CLOUD, 1, 1, 15);
public static final SpawnEntry SPAWN_ENTRY_OCEAN = new SpawnEntry(UEntities.WILD_CLOUD, 1, 1, 7);
public WildCloudEntity(EntityType<WildCloudEntity> type, World world) {
super(type, world);