Integrations prototype
This commit is contained in:
parent
26e9f79def
commit
eadeba4593
7 changed files with 110 additions and 2 deletions
|
@ -7,6 +7,7 @@ import ru.betterend.api.BetterEndPlugin;
|
|||
import ru.betterend.config.Configs;
|
||||
import ru.betterend.effects.EndEnchantments;
|
||||
import ru.betterend.effects.EndPotions;
|
||||
import ru.betterend.integration.Integrations;
|
||||
import ru.betterend.item.GuideBook;
|
||||
import ru.betterend.recipe.AlloyingRecipes;
|
||||
import ru.betterend.recipe.CraftingRecipes;
|
||||
|
@ -49,6 +50,7 @@ public class BetterEnd implements ModInitializer {
|
|||
SmithingRecipes.register();
|
||||
InfusionRecipes.register();
|
||||
EndStructures.register();
|
||||
Integrations.register();
|
||||
|
||||
if (hasGuideBook()) {
|
||||
GuideBook.register();
|
||||
|
|
25
src/main/java/ru/betterend/integration/Integrations.java
Normal file
25
src/main/java/ru/betterend/integration/Integrations.java
Normal file
|
@ -0,0 +1,25 @@
|
|||
package ru.betterend.integration;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import ru.betterend.integration.byg.BYGIntegration;
|
||||
|
||||
public class Integrations {
|
||||
public static final List<ModIntegration> INTEGRATIONS = Lists.newArrayList();
|
||||
public static final ModIntegration BYG = register(new BYGIntegration());
|
||||
|
||||
public static void register() {
|
||||
INTEGRATIONS.forEach((integration) -> {
|
||||
if (integration.modIsInstalled()) {
|
||||
integration.register();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static ModIntegration register(ModIntegration integration) {
|
||||
INTEGRATIONS.add(integration);
|
||||
return integration;
|
||||
}
|
||||
}
|
39
src/main/java/ru/betterend/integration/ModIntegration.java
Normal file
39
src/main/java/ru/betterend/integration/ModIntegration.java
Normal file
|
@ -0,0 +1,39 @@
|
|||
package ru.betterend.integration;
|
||||
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.registry.RegistryKey;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
||||
public abstract class ModIntegration {
|
||||
private final String modID;
|
||||
|
||||
public ModIntegration(String modID) {
|
||||
this.modID = modID;
|
||||
}
|
||||
|
||||
public Identifier getID(String name) {
|
||||
return new Identifier(modID, name);
|
||||
}
|
||||
|
||||
public Block getBlock(String name) {
|
||||
return Registry.BLOCK.get(getID(name));
|
||||
}
|
||||
|
||||
public BlockState getDefaultState(String name) {
|
||||
return getBlock(name).getDefaultState();
|
||||
}
|
||||
|
||||
public RegistryKey<Biome> getKey(String name) {
|
||||
return RegistryKey.of(Registry.BIOME_KEY, getID(name));
|
||||
}
|
||||
|
||||
public boolean modIsInstalled() {
|
||||
return FabricLoader.getInstance().isModLoaded(modID);
|
||||
}
|
||||
|
||||
public abstract void register();
|
||||
}
|
16
src/main/java/ru/betterend/integration/byg/BYGBiomes.java
Normal file
16
src/main/java/ru/betterend/integration/byg/BYGBiomes.java
Normal file
|
@ -0,0 +1,16 @@
|
|||
package ru.betterend.integration.byg;
|
||||
|
||||
import ru.betterend.integration.Integrations;
|
||||
import ru.betterend.registry.EndBiomes;
|
||||
import ru.betterend.world.biome.EndBiome;
|
||||
import ru.betterend.world.generator.BiomeType;
|
||||
|
||||
public class BYGBiomes {
|
||||
// Original Biomes
|
||||
public static final EndBiome BULBIS_GARDENS = EndBiomes.registerBiome(Integrations.BYG.getKey("bulbis_gardens"), BiomeType.LAND, 1F);
|
||||
|
||||
// New Biomes
|
||||
public static final EndBiome OLD_BULBIS_GARDENS = EndBiomes.registerSubBiome(new OldBulbisGardens(), BULBIS_GARDENS);
|
||||
|
||||
public static void register() {}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package ru.betterend.integration.byg;
|
||||
|
||||
import ru.betterend.integration.ModIntegration;
|
||||
|
||||
public class BYGIntegration extends ModIntegration {
|
||||
public BYGIntegration() {
|
||||
super("byg");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
BYGBiomes.register();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package ru.betterend.integration.byg;
|
||||
|
||||
import ru.betterend.integration.Integrations;
|
||||
import ru.betterend.world.biome.BiomeDefinition;
|
||||
import ru.betterend.world.biome.EndBiome;
|
||||
|
||||
public class OldBulbisGardens extends EndBiome {
|
||||
public OldBulbisGardens() {
|
||||
super(new BiomeDefinition("old_bulbis_gardens")
|
||||
.setSurface(Integrations.BYG.getBlock("bulbis_stem")));
|
||||
}
|
||||
}
|
|
@ -295,11 +295,11 @@ public class EndBiomes {
|
|||
return biome;
|
||||
}
|
||||
|
||||
private static EndBiome registerBiome(RegistryKey<Biome> key, BiomeType type, float genChance) {
|
||||
public static EndBiome registerBiome(RegistryKey<Biome> key, BiomeType type, float genChance) {
|
||||
return registerBiome(BuiltinRegistries.BIOME.get(key), type, genChance);
|
||||
}
|
||||
|
||||
private static EndBiome registerSubBiome(RegistryKey<Biome> key, EndBiome parent, float genChance) {
|
||||
public static EndBiome registerSubBiome(RegistryKey<Biome> key, EndBiome parent, float genChance) {
|
||||
return registerSubBiome(BuiltinRegistries.BIOME.get(key), parent, genChance, true);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue