Merge branch 'master' of https://github.com/paulevsGitch/BetterEnd.git
This commit is contained in:
commit
71cae4850c
2 changed files with 24 additions and 10 deletions
|
@ -1,19 +1,23 @@
|
|||
package ru.betterend.config;
|
||||
|
||||
public class Configs {
|
||||
public static final IdConfig ITEM_CONFIG = new IdConfig("items", (item, category) -> {
|
||||
return new ConfigKey(item.getNamespace(), category, item.getPath());
|
||||
public static final IdConfig ITEM_CONFIG = new IdConfig("items", (itemId, category) -> {
|
||||
return new ConfigKey(itemId.getNamespace(), category, itemId.getPath());
|
||||
});
|
||||
public static final IdConfig BLOCK_CONFIG = new IdConfig("blocks", (block, category) -> {
|
||||
return new ConfigKey(block.getNamespace(), category, block.getPath());
|
||||
public static final IdConfig BLOCK_CONFIG = new IdConfig("blocks", (blockId, category) -> {
|
||||
return new ConfigKey(blockId.getNamespace(), category, blockId.getPath());
|
||||
});
|
||||
public static final IdConfig BIOME_CONFIG = new IdConfig("biomes", (biome, entry) -> {
|
||||
return new ConfigKey(biome.getNamespace(), biome.getPath(), entry);
|
||||
public static final IdConfig BIOME_CONFIG = new IdConfig("biomes", (biomeId, entry) -> {
|
||||
return new ConfigKey(biomeId.getNamespace(), biomeId.getPath(), entry);
|
||||
});
|
||||
public static final IdConfig ENTITY_CONFIG = new IdConfig("entities", (entityId, category) -> {
|
||||
return new ConfigKey(entityId.getNamespace(), category, entityId.getPath());
|
||||
});
|
||||
|
||||
public static void saveConfigs() {
|
||||
ITEM_CONFIG.saveChanges();
|
||||
BLOCK_CONFIG.saveChanges();
|
||||
BIOME_CONFIG.saveChanges();
|
||||
ENTITY_CONFIG.saveChanges();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,8 +9,10 @@ import net.minecraft.entity.EntityType.EntityFactory;
|
|||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.SpawnGroup;
|
||||
import net.minecraft.entity.attribute.DefaultAttributeContainer.Builder;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.config.Configs;
|
||||
import ru.betterend.entity.EntityCubozoa;
|
||||
import ru.betterend.entity.EntityDragonfly;
|
||||
import ru.betterend.entity.EntityEndFish;
|
||||
|
@ -35,14 +37,22 @@ public class EndEntities {
|
|||
}
|
||||
|
||||
protected static <T extends Entity> EntityType<T> register(String name, SpawnGroup group, float width, float height, EntityFactory<T> entity) {
|
||||
EntityType<T> type = Registry.register(Registry.ENTITY_TYPE, BetterEnd.makeID(name), FabricEntityTypeBuilder.<T>create(group, entity).dimensions(EntityDimensions.fixed(width, height)).build());
|
||||
Identifier id = BetterEnd.makeID(name);
|
||||
EntityType<T> type = FabricEntityTypeBuilder.<T>create(group, entity).dimensions(EntityDimensions.fixed(width, height)).build();
|
||||
if (Configs.ENTITY_CONFIG.getBoolean(id, "entities", true)) {
|
||||
return Registry.register(Registry.ENTITY_TYPE, id, type);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
private static <T extends LivingEntity> EntityType<T> register(String name, SpawnGroup group, float width, float height, EntityFactory<T> entity, Builder attributes, boolean fixedSize, int eggColor, int dotsColor) {
|
||||
EntityType<T> type = Registry.register(Registry.ENTITY_TYPE, BetterEnd.makeID(name), FabricEntityTypeBuilder.<T>create(group, entity).dimensions(fixedSize ? EntityDimensions.fixed(width, height) : EntityDimensions.changing(width, height)).build());
|
||||
Identifier id = BetterEnd.makeID(name);
|
||||
EntityType<T> type = FabricEntityTypeBuilder.<T>create(group, entity).dimensions(fixedSize ? EntityDimensions.fixed(width, height) : EntityDimensions.changing(width, height)).build();
|
||||
if (Configs.ENTITY_CONFIG.getBoolean(id, "entities", true)) {
|
||||
FabricDefaultAttributeRegistry.register(type, attributes);
|
||||
EndItems.registerEgg("spawn_egg_" + name, type, eggColor, dotsColor);
|
||||
return Registry.register(Registry.ENTITY_TYPE, BetterEnd.makeID(name), type);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue