mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-12-22 19:39:24 +01:00
Move Entity registration code to InitEntities
Move BiomeModifier and Condition registration code to ActuallyBiomeModifiers
This commit is contained in:
parent
09592c6f41
commit
84c7b0d61a
6 changed files with 50 additions and 35 deletions
|
@ -26,6 +26,7 @@ import de.ellpeck.actuallyadditions.mod.entity.EntityWorm;
|
|||
import de.ellpeck.actuallyadditions.mod.entity.InitEntities;
|
||||
import de.ellpeck.actuallyadditions.mod.event.CommonEvents;
|
||||
import de.ellpeck.actuallyadditions.mod.fluids.InitFluids;
|
||||
import de.ellpeck.actuallyadditions.mod.gen.ActuallyBiomeModifiers;
|
||||
import de.ellpeck.actuallyadditions.mod.gen.ActuallyVillages;
|
||||
import de.ellpeck.actuallyadditions.mod.gen.modifier.BoolConfigFeatureBiomeModifier;
|
||||
import de.ellpeck.actuallyadditions.mod.gen.village.ActuallyPOITypes;
|
||||
|
@ -89,22 +90,6 @@ public class ActuallyAdditions {
|
|||
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger(MODID);
|
||||
|
||||
private static final DeferredRegister<EntityType<?>> ENTITIES = DeferredRegister.create(BuiltInRegistries.ENTITY_TYPE, MODID);
|
||||
public static final Supplier<EntityType<EntityWorm>> ENTITY_WORM = ENTITIES.register("worm", () -> EntityType.Builder.of(EntityWorm::new, MobCategory.MISC).build(MODID + ":worm"));
|
||||
|
||||
private static final DeferredRegister<MapCodec<? extends ICondition>> CONDITION_CODECS = DeferredRegister.create(NeoForgeRegistries.Keys.CONDITION_CODECS, MODID);
|
||||
public static final DeferredHolder<MapCodec<? extends ICondition>, MapCodec<BoolConfigCondition>> BOOL_CONFIG_CONDITION = CONDITION_CODECS.register("bool_config_condition", () -> BoolConfigCondition.CODEC);
|
||||
|
||||
public static final DeferredRegister<MapCodec<? extends BiomeModifier>> BIOME_MODIFIER_SERIALIZERS = DeferredRegister.create(NeoForgeRegistries.Keys.BIOME_MODIFIER_SERIALIZERS, MODID);
|
||||
public static final Supplier<MapCodec<BoolConfigFeatureBiomeModifier>> BOOL_CONFIG_MODIFIER = BIOME_MODIFIER_SERIALIZERS.register("bool_config_feature_modifier", () ->
|
||||
RecordCodecBuilder.mapCodec(builder -> builder.group(
|
||||
Biome.LIST_CODEC.fieldOf("biomes").forGetter(BoolConfigFeatureBiomeModifier::biomes),
|
||||
PlacedFeature.LIST_CODEC.fieldOf("features").forGetter(BoolConfigFeatureBiomeModifier::features),
|
||||
GenerationStep.Decoration.CODEC.fieldOf("step").forGetter(BoolConfigFeatureBiomeModifier::step),
|
||||
Codec.STRING.fieldOf("boolConfig").forGetter(BoolConfigFeatureBiomeModifier::boolConfig)
|
||||
).apply(builder, BoolConfigFeatureBiomeModifier::new))
|
||||
);
|
||||
|
||||
public static boolean commonCapsLoaded;
|
||||
|
||||
public ActuallyAdditions(IEventBus eventBus, ModContainer container, Dist dist) {
|
||||
|
@ -121,9 +106,9 @@ public class ActuallyAdditions {
|
|||
ActuallyLootModifiers.init(eventBus);
|
||||
ActuallyContainers.CONTAINERS.register(eventBus);
|
||||
ArmorMaterials.init(eventBus);
|
||||
ENTITIES.register(eventBus);
|
||||
CONDITION_CODECS.register(eventBus);
|
||||
BIOME_MODIFIER_SERIALIZERS.register(eventBus);
|
||||
InitEntities.init(eventBus);
|
||||
InitFluids.init(eventBus);
|
||||
ActuallyBiomeModifiers.init(eventBus);
|
||||
eventBus.addListener(this::onConfigReload);
|
||||
ActuallyParticles.init(eventBus);
|
||||
ActuallyTags.init();
|
||||
|
@ -136,7 +121,6 @@ public class ActuallyAdditions {
|
|||
NeoForge.EVENT_BUS.addListener(ActuallyAdditions::reloadEvent);
|
||||
NeoForge.EVENT_BUS.addListener(Worm::onHoe);
|
||||
NeoForge.EVENT_BUS.addListener(ActuallyVillages::modifyVillageStructures);
|
||||
InitFluids.init(eventBus);
|
||||
|
||||
eventBus.addListener(PacketHandler::register);
|
||||
eventBus.addListener(this::setup);
|
||||
|
@ -164,7 +148,6 @@ public class ActuallyAdditions {
|
|||
commonCapsLoaded = false; // Loader.isModLoaded("commoncapabilities");
|
||||
|
||||
new UpdateChecker();
|
||||
InitEntities.init(); // todo: [port] replace
|
||||
}
|
||||
|
||||
private void onConfigReload(ModConfigEvent event) {
|
||||
|
|
|
@ -16,6 +16,7 @@ import de.ellpeck.actuallyadditions.mod.blocks.render.RenderBatteryBox;
|
|||
import de.ellpeck.actuallyadditions.mod.blocks.render.RenderDisplayStand;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.render.RenderEmpowerer;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.render.RenderLaserRelay;
|
||||
import de.ellpeck.actuallyadditions.mod.entity.InitEntities;
|
||||
import de.ellpeck.actuallyadditions.mod.entity.RenderWorm;
|
||||
import de.ellpeck.actuallyadditions.mod.event.ClientEvents;
|
||||
import de.ellpeck.actuallyadditions.mod.fluids.InitFluids;
|
||||
|
@ -142,7 +143,7 @@ public class ActuallyAdditionsClient {
|
|||
event.registerBlockEntityRenderer(ActuallyBlocks.LASER_RELAY_ITEM_ADVANCED.getTileEntityType(), RenderLaserRelay::new);
|
||||
event.registerBlockEntityRenderer(ActuallyBlocks.LASER_RELAY_FLUIDS.getTileEntityType(), RenderLaserRelay::new);
|
||||
|
||||
event.registerEntityRenderer(ActuallyAdditions.ENTITY_WORM.get(), RenderWorm::new);
|
||||
event.registerEntityRenderer(InitEntities.ENTITY_WORM.get(), RenderWorm::new);
|
||||
}
|
||||
|
||||
public static void registerParticleFactories(RegisterParticleProvidersEvent event) {
|
||||
|
|
|
@ -11,19 +11,19 @@
|
|||
package de.ellpeck.actuallyadditions.mod.entity;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.MobCategory;
|
||||
import net.neoforged.bus.api.IEventBus;
|
||||
import net.neoforged.neoforge.registries.DeferredRegister;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public final class InitEntities {
|
||||
private static final DeferredRegister<EntityType<?>> ENTITIES = DeferredRegister.create(BuiltInRegistries.ENTITY_TYPE, ActuallyAdditions.MODID);
|
||||
public static final Supplier<EntityType<EntityWorm>> ENTITY_WORM = ENTITIES.register("worm", () -> EntityType.Builder.of(EntityWorm::new, MobCategory.MISC).build(ActuallyAdditions.MODID + ":worm"));
|
||||
|
||||
public static void init() {
|
||||
ActuallyAdditions.LOGGER.info("Initializing Entities...");
|
||||
|
||||
//EntityRegistry.registerModEntity(ActuallyAdditions.modLoc("worm"), EntityWorm.class, ActuallyAdditions.MODID + ".worm", 0, ActuallyAdditions.INSTANCE, 64, 1, false);
|
||||
public static void init(IEventBus bus) {
|
||||
ENTITIES.register(bus);
|
||||
}
|
||||
|
||||
|
||||
public static void initClient() {
|
||||
//RenderingRegistry.registerEntityRenderingHandler(EntityWorm.class, RenderWorm::new);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
package de.ellpeck.actuallyadditions.mod.gen;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.config.conditions.BoolConfigCondition;
|
||||
import de.ellpeck.actuallyadditions.mod.gen.modifier.BoolConfigFeatureBiomeModifier;
|
||||
import net.minecraft.core.HolderGetter;
|
||||
import net.minecraft.core.HolderSet;
|
||||
|
@ -11,10 +15,35 @@ import net.minecraft.tags.BiomeTags;
|
|||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.levelgen.GenerationStep;
|
||||
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
||||
import net.neoforged.bus.api.IEventBus;
|
||||
import net.neoforged.neoforge.common.conditions.ICondition;
|
||||
import net.neoforged.neoforge.common.world.BiomeModifier;
|
||||
import net.neoforged.neoforge.registries.DeferredHolder;
|
||||
import net.neoforged.neoforge.registries.DeferredRegister;
|
||||
import net.neoforged.neoforge.registries.NeoForgeRegistries;
|
||||
|
||||
public class ActuallyBiomeModifiers {
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public final class ActuallyBiomeModifiers {
|
||||
private static final DeferredRegister<MapCodec<? extends ICondition>> CONDITION_CODECS = DeferredRegister.create(NeoForgeRegistries.Keys.CONDITION_CODECS, ActuallyAdditions.MODID);
|
||||
public static final DeferredHolder<MapCodec<? extends ICondition>, MapCodec<BoolConfigCondition>> BOOL_CONFIG_CONDITION = CONDITION_CODECS.register("bool_config_condition", () -> BoolConfigCondition.CODEC);
|
||||
|
||||
public static final DeferredRegister<MapCodec<? extends BiomeModifier>> BIOME_MODIFIER_SERIALIZERS = DeferredRegister.create(NeoForgeRegistries.Keys.BIOME_MODIFIER_SERIALIZERS, ActuallyAdditions.MODID);
|
||||
public static final Supplier<MapCodec<BoolConfigFeatureBiomeModifier>> BOOL_CONFIG_MODIFIER = BIOME_MODIFIER_SERIALIZERS.register("bool_config_feature_modifier", () ->
|
||||
RecordCodecBuilder.mapCodec(builder -> builder.group(
|
||||
Biome.LIST_CODEC.fieldOf("biomes").forGetter(BoolConfigFeatureBiomeModifier::biomes),
|
||||
PlacedFeature.LIST_CODEC.fieldOf("features").forGetter(BoolConfigFeatureBiomeModifier::features),
|
||||
GenerationStep.Decoration.CODEC.fieldOf("step").forGetter(BoolConfigFeatureBiomeModifier::step),
|
||||
Codec.STRING.fieldOf("boolConfig").forGetter(BoolConfigFeatureBiomeModifier::boolConfig)
|
||||
).apply(builder, BoolConfigFeatureBiomeModifier::new))
|
||||
);
|
||||
|
||||
public static void init(IEventBus bus) {
|
||||
CONDITION_CODECS.register(bus);
|
||||
BIOME_MODIFIER_SERIALIZERS.register(bus);
|
||||
}
|
||||
|
||||
|
||||
protected static final ResourceKey<BiomeModifier> ADD_BLACK_QUARTZ_ORE_MODIFIER = ResourceKey.create(NeoForgeRegistries.Keys.BIOME_MODIFIERS,
|
||||
ActuallyAdditions.modLoc("add_black_quartz"));
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package de.ellpeck.actuallyadditions.mod.gen.modifier;
|
|||
import com.mojang.serialization.MapCodec;
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.config.CommonConfig;
|
||||
import de.ellpeck.actuallyadditions.mod.gen.ActuallyBiomeModifiers;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.HolderSet;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
|
@ -34,6 +35,6 @@ public record BoolConfigFeatureBiomeModifier(HolderSet<Biome> biomes, HolderSet<
|
|||
|
||||
@Override
|
||||
public MapCodec<? extends BiomeModifier> codec() {
|
||||
return ActuallyAdditions.BOOL_CONFIG_MODIFIER.get();
|
||||
return ActuallyBiomeModifiers.BOOL_CONFIG_MODIFIER.get();
|
||||
}
|
||||
}
|
|
@ -13,6 +13,7 @@ package de.ellpeck.actuallyadditions.mod.items;
|
|||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.config.CommonConfig;
|
||||
import de.ellpeck.actuallyadditions.mod.entity.EntityWorm;
|
||||
import de.ellpeck.actuallyadditions.mod.entity.InitEntities;
|
||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
|
@ -48,7 +49,7 @@ public class Worm extends ItemBase {
|
|||
if (!worms.isEmpty())
|
||||
return super.useOn(context);
|
||||
|
||||
EntityWorm worm = new EntityWorm(ActuallyAdditions.ENTITY_WORM.get(), level);
|
||||
EntityWorm worm = new EntityWorm(InitEntities.ENTITY_WORM.get(), level);
|
||||
worm.setPos(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
|
||||
worm.setCustomName(stack.getHoverName());
|
||||
level.addFreshEntity(worm);
|
||||
|
|
Loading…
Reference in a new issue