BYG crash fix, BYG end sub-biome support, Old Bulbis Gardens
improvements
This commit is contained in:
parent
7ef23332fc
commit
38a09c7221
10 changed files with 183 additions and 53 deletions
|
@ -1,9 +1,5 @@
|
|||
package ru.betterend.integration;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import ru.betterend.BetterEnd;
|
||||
|
||||
public class AdornIntegration extends ModIntegration {
|
||||
public AdornIntegration() {
|
||||
super("adorn");
|
||||
|
@ -11,15 +7,15 @@ public class AdornIntegration extends ModIntegration {
|
|||
|
||||
@Override
|
||||
public void register() {
|
||||
Class<?> adornBlockBuilder = getClass("juuxel.adorn.api.block.AdornBlockBuilder");
|
||||
Class<?> blockVariantWood = getClass("juuxel.adorn.api.block.BlockVariant$Wood");
|
||||
Class<?> blockVariant = getClass("juuxel.adorn.api.block.BlockVariant");
|
||||
//Class<?> adornBlockBuilder = getClass("juuxel.adorn.api.block.AdornBlockBuilder");
|
||||
//Class<?> blockVariantWood = getClass("juuxel.adorn.api.block.BlockVariant$Wood");
|
||||
//Class<?> blockVariant = getClass("juuxel.adorn.api.block.BlockVariant");
|
||||
|
||||
Object testVariant = newInstance(blockVariantWood, BetterEnd.MOD_ID + "/mossy_glowshroom");
|
||||
Method create = getMethod(adornBlockBuilder, "create", blockVariant);
|
||||
Object builder = executeMethod(adornBlockBuilder, create, testVariant);
|
||||
getAndExecuteRuntime(builder, "withEverything");
|
||||
getAndExecuteRuntime(builder, "registerIn", BetterEnd.MOD_ID);
|
||||
//Object testVariant = newInstance(blockVariantWood, BetterEnd.MOD_ID + "/mossy_glowshroom");
|
||||
//Method create = getMethod(adornBlockBuilder, "create", blockVariant);
|
||||
//Object builder = executeMethod(adornBlockBuilder, create, testVariant);
|
||||
//getAndExecuteRuntime(builder, "withEverything");
|
||||
//getAndExecuteRuntime(builder, "registerIn", BetterEnd.MOD_ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package ru.betterend.integration;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
|
@ -87,25 +88,41 @@ public abstract class ModIntegration {
|
|||
return cl;
|
||||
}
|
||||
|
||||
public Method getMethod(Class<?> cl, String functionName, Class<?>... args) {
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends Object> T getStaticFieldValue(Class<?> cl, String name) {
|
||||
if (cl != null) {
|
||||
try {
|
||||
return cl.getMethod(functionName, args);
|
||||
Field field = cl.getDeclaredField(name);
|
||||
if (field != null) {
|
||||
return (T) field.get(null);
|
||||
}
|
||||
catch (NoSuchMethodException | SecurityException e) {
|
||||
BetterEnd.LOGGER.error(e.getMessage());
|
||||
if (BetterEnd.isDevEnvironment()) {
|
||||
}
|
||||
catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Method getInstanceMethod(Object instance, String functionName, Class<?>... args) {
|
||||
if (instance != null) {
|
||||
public Object getFieldValue(Class<?> cl, String name, Object classInstance) {
|
||||
if (cl != null) {
|
||||
try {
|
||||
return instance.getClass().getDeclaredMethod(functionName, args);
|
||||
Field field = cl.getDeclaredField(name);
|
||||
if (field != null) {
|
||||
return field.get(classInstance);
|
||||
}
|
||||
}
|
||||
catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Method getMethod(Class<?> cl, String functionName, Class<?>... args) {
|
||||
if (cl != null) {
|
||||
try {
|
||||
return cl.getMethod(functionName, args);
|
||||
}
|
||||
catch (NoSuchMethodException | SecurityException e) {
|
||||
BetterEnd.LOGGER.error(e.getMessage());
|
||||
|
@ -144,14 +161,15 @@ public abstract class ModIntegration {
|
|||
return null;
|
||||
}
|
||||
|
||||
public Object getAndExecuteRuntime(Object instance, String functionName, Object... args) {
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends Object> T getAndExecuteRuntime(Class<?> cl, Object instance, String functionName, Object... args) {
|
||||
if (instance != null) {
|
||||
Class<?>[] classes = new Class<?>[args.length];
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
classes[i] = args[i].getClass();
|
||||
}
|
||||
Method method = getInstanceMethod(instance, functionName, classes);
|
||||
return executeMethod(instance, method, args);
|
||||
Method method = getMethod(cl, functionName, classes);
|
||||
return (T) executeMethod(instance, method, args);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -1,11 +1,20 @@
|
|||
package ru.betterend.integration.byg;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.collection.WeightedList;
|
||||
import net.minecraft.util.registry.BuiltinRegistries;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import ru.betterend.integration.Integrations;
|
||||
import ru.betterend.integration.ModIntegration;
|
||||
import ru.betterend.integration.byg.biomes.BYGBiomes;
|
||||
import ru.betterend.integration.byg.features.BYGFeatures;
|
||||
import ru.betterend.registry.EndBiomes;
|
||||
import ru.betterend.registry.EndTags;
|
||||
import ru.betterend.util.TagHelper;
|
||||
import ru.betterend.world.biome.EndBiome;
|
||||
|
||||
public class BYGIntegration extends ModIntegration {
|
||||
public BYGIntegration() {
|
||||
|
@ -23,5 +32,46 @@ public class BYGIntegration extends ModIntegration {
|
|||
@Override
|
||||
public void addBiomes() {
|
||||
BYGBiomes.addBiomes();
|
||||
|
||||
Class<?> biomeClass = this.getClass("corgiaoc.byg.common.world.biome.BYGEndBiome");
|
||||
List<Object> biomes = this.getStaticFieldValue(biomeClass, "BYG_END_BIOMES");
|
||||
|
||||
if (biomes != null && biomeClass != null) {
|
||||
biomes.forEach((obj) -> {
|
||||
Biome biome = this.getAndExecuteRuntime(biomeClass, obj, "getBiome");
|
||||
if (biome != null) {
|
||||
Identifier biomeID = BuiltinRegistries.BIOME.getId(biome);
|
||||
EndBiome endBiome = EndBiomes.getBiome(biomeID);
|
||||
Biome edge = this.getAndExecuteRuntime(biomeClass, obj, "getEdge");
|
||||
if (edge != null) {
|
||||
Identifier edgeID = BuiltinRegistries.BIOME.getId(edge);
|
||||
EndBiomes.LAND_BIOMES.removeMutableBiome(edgeID);
|
||||
EndBiomes.VOID_BIOMES.removeMutableBiome(edgeID);
|
||||
EndBiome edgeBiome = EndBiomes.getBiome(edgeID);
|
||||
endBiome.setEdge(edgeBiome);
|
||||
endBiome.setEdgeSize(32);
|
||||
}
|
||||
else {
|
||||
boolean isVoid = this.getAndExecuteRuntime(biomeClass, obj, "isVoid");
|
||||
if (isVoid) {
|
||||
EndBiomes.LAND_BIOMES.removeMutableBiome(biomeID);
|
||||
EndBiomes.VOID_BIOMES.addBiome(endBiome);
|
||||
}
|
||||
WeightedList<Identifier> subBiomes = this.getAndExecuteRuntime(biomeClass, obj, "getHills");
|
||||
if (subBiomes != null) {
|
||||
subBiomes.stream().collect(Collectors.toList()).forEach((id) -> {
|
||||
EndBiome subBiome = EndBiomes.getBiome(id);
|
||||
EndBiomes.LAND_BIOMES.removeMutableBiome(id);
|
||||
EndBiomes.VOID_BIOMES.removeMutableBiome(id);
|
||||
if (!endBiome.containsSubBiome(subBiome)) {
|
||||
EndBiomes.SUBBIOMES.add(subBiome);
|
||||
endBiome.addSubBiome(subBiome);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,21 @@
|
|||
package ru.betterend.integration.byg.biomes;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.SpawnGroup;
|
||||
import net.minecraft.particle.ParticleTypes;
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.BuiltinRegistries;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.BiomeEffects;
|
||||
import net.minecraft.world.biome.SpawnSettings.SpawnEntry;
|
||||
import net.minecraft.world.gen.GenerationStep.Feature;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeatures;
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.integration.Integrations;
|
||||
import ru.betterend.integration.byg.features.BYGFeatures;
|
||||
|
@ -25,24 +32,17 @@ public class OldBulbisGardens extends EndBiome {
|
|||
Biome biome = Integrations.BYG.getBiome("bulbis_gardens");
|
||||
BiomeEffects effects = biome.getEffects();
|
||||
|
||||
Block ivis = Integrations.BYG.getBlock("ivis_phylium");
|
||||
Block origin = biome.getGenerationSettings().getSurfaceConfig().getTopMaterial().getBlock();
|
||||
BiomeDefinition def = new BiomeDefinition("old_bulbis_gardens")
|
||||
.setFogColor(215, 132, 207)
|
||||
.setFogDensity(1.8F)
|
||||
.setWaterAndFogColor(40, 0, 56)
|
||||
.setFoliageColor(122, 17, 155)
|
||||
.setParticles(ParticleTypes.REVERSE_PORTAL, 0.002F)
|
||||
.setSurface(Integrations.BYG.getBlock("ivis_phylium"))
|
||||
.setSurface(ivis, origin)
|
||||
.addFeature(EndFeatures.END_LAKE_RARE)
|
||||
.addFeature(BYGFeatures.OLD_BULBIS_TREE)
|
||||
.addFeature(Feature.VEGETAL_DECORATION, BYGFeatures.BULBIS_TREES)
|
||||
.addFeature(Feature.VEGETAL_DECORATION, BYGFeatures.PURPLE_BULBIS_TREES)
|
||||
.addFeature(EndFeatures.PURPLE_POLYPORE)
|
||||
.addFeature(BYGFeatures.IVIS_MOSS_WOOD)
|
||||
.addFeature(BYGFeatures.IVIS_MOSS)
|
||||
.addFeature(BYGFeatures.IVIS_VINE)
|
||||
.addFeature(BYGFeatures.IVIS_SPROUT)
|
||||
.addFeature(BYGFeatures.BULBIS_ODDITY)
|
||||
.addFeature(BYGFeatures.PURPLE_BULBIS_ODDITY);
|
||||
.addFeature(BYGFeatures.OLD_BULBIS_TREE);
|
||||
|
||||
if (BetterEnd.isClient()) {
|
||||
SoundEvent loop = effects.getLoopSound().get();
|
||||
|
@ -59,6 +59,33 @@ public class OldBulbisGardens extends EndBiome {
|
|||
});
|
||||
}
|
||||
|
||||
List<List<Supplier<ConfiguredFeature<?, ?>>>> features = biome.getGenerationSettings().getFeatures();
|
||||
List<Supplier<ConfiguredFeature<?, ?>>> vegetal = features.get(Feature.VEGETAL_DECORATION.ordinal());
|
||||
if (vegetal.size() > 2) {
|
||||
Supplier<ConfiguredFeature<?, ?>> getter;
|
||||
// Trees (first two features)
|
||||
// I couldn't process them with conditions, so that's why they are hardcoded (paulevs)
|
||||
for (int i = 0; i < 2; i++) {
|
||||
getter = vegetal.get(i);
|
||||
ConfiguredFeature<?, ?> feature = getter.get();
|
||||
Identifier id = BetterEnd.makeID("obg_feature_" + i);
|
||||
feature = Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, id, feature.decorate(ConfiguredFeatures.Decorators.SQUARE_HEIGHTMAP).repeatRandomly(1));
|
||||
def.addFeature(Feature.VEGETAL_DECORATION, feature);
|
||||
}
|
||||
// Grasses and other features
|
||||
for (int i = 2; i < vegetal.size(); i++) {
|
||||
getter = vegetal.get(i);
|
||||
ConfiguredFeature<?, ?> feature = getter.get();
|
||||
def.addFeature(Feature.VEGETAL_DECORATION, feature);
|
||||
}
|
||||
}
|
||||
|
||||
def.addFeature(EndFeatures.PURPLE_POLYPORE)
|
||||
.addFeature(BYGFeatures.IVIS_MOSS_WOOD)
|
||||
.addFeature(BYGFeatures.IVIS_MOSS)
|
||||
.addFeature(BYGFeatures.IVIS_VINE)
|
||||
.addFeature(BYGFeatures.IVIS_SPROUT);
|
||||
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package ru.betterend.integration.byg.features;
|
||||
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
import ru.betterend.integration.Integrations;
|
||||
import ru.betterend.integration.byg.BYGBlocks;
|
||||
import ru.betterend.world.features.EndFeature;
|
||||
|
@ -23,8 +22,8 @@ public class BYGFeatures {
|
|||
public static final EndFeature NIGHTSHADE_REDWOOD_TREE = new EndFeature("nightshade_redwood_tree", new NightshadeRedwoodTreeFeature(), 1);
|
||||
public static final EndFeature BIG_ETHER_TREE = new EndFeature("big_ether_tree", new BigEtherTreeFeature(), 1);
|
||||
|
||||
public static final ConfiguredFeature<?,?> BULBIS_TREES = Integrations.BYG.getConfiguredFeature("rs_sparse_bulbis_tree");
|
||||
public static final ConfiguredFeature<?,?> PURPLE_BULBIS_TREES = Integrations.BYG.getConfiguredFeature("rs_sparse_purple_bulbis_tree");
|
||||
//public static final ConfiguredFeature<?,?> BULBIS_TREES = Integrations.BYG.getConfiguredFeature("rs_sparse_bulbis_tree");
|
||||
//public static final ConfiguredFeature<?,?> PURPLE_BULBIS_TREES = Integrations.BYG.getConfiguredFeature("rs_sparse_purple_bulbis_tree");
|
||||
|
||||
public static void register() {}
|
||||
}
|
||||
|
|
|
@ -53,7 +53,10 @@ public class OldBulbisTreeFeature extends DefaultFeature {
|
|||
};
|
||||
|
||||
float size = MHelper.randRange(10, 20, random);
|
||||
float addSize = MHelper.randRange(1, 1.7F, random);
|
||||
float addRad = addSize * 0.5F + 0.5F;
|
||||
int count = (int) (size * 0.15F);
|
||||
size *= addSize;
|
||||
float var = MHelper.PI2 / (float) (count * 3);
|
||||
float start = MHelper.randRange(0, MHelper.PI2, random);
|
||||
SDF sdf = null;
|
||||
|
@ -65,10 +68,10 @@ public class OldBulbisTreeFeature extends DefaultFeature {
|
|||
List<Vector3f> spline = SplineHelper.copySpline(SPLINE);
|
||||
float sizeXZ = (size + MHelper.randRange(0, size * 0.5F, random)) * 0.7F;
|
||||
SplineHelper.scale(spline, sizeXZ, sizeXZ * 1.5F + MHelper.randRange(0, size * 0.5F, random), sizeXZ);
|
||||
SplineHelper.offset(spline, new Vector3f((20 - size), 0, 0));
|
||||
SplineHelper.offset(spline, new Vector3f(size * random.nextFloat() * 0.3F, 0, 0));
|
||||
SplineHelper.rotateSpline(spline, angle);
|
||||
SplineHelper.offsetParts(spline, random, 1F, 0, 1F);//1.3F 0.8F
|
||||
SDF branch = SplineHelper.buildSDF(spline, 2.3F, 1.3F, (bpos) -> {
|
||||
SDF branch = SplineHelper.buildSDF(spline, 2.3F * addRad, 1.3F * addRad, (bpos) -> {
|
||||
return stem;
|
||||
});
|
||||
|
||||
|
|
|
@ -144,18 +144,15 @@ public class EndBiomes {
|
|||
VOID_BIOMES.rebuild();
|
||||
|
||||
LAND_BIOMES.getBiomes().forEach((endBiome) -> {
|
||||
Biome biome = biomeRegistry.get(endBiome.getID());
|
||||
endBiome.setActualBiome(biome);
|
||||
endBiome.updateActualBiomes(biomeRegistry);
|
||||
});
|
||||
|
||||
VOID_BIOMES.getBiomes().forEach((endBiome) -> {
|
||||
Biome biome = biomeRegistry.get(endBiome.getID());
|
||||
endBiome.setActualBiome(biome);
|
||||
endBiome.updateActualBiomes(biomeRegistry);
|
||||
});
|
||||
|
||||
SUBBIOMES.forEach((endBiome) -> {
|
||||
Biome biome = biomeRegistry.get(endBiome.getID());
|
||||
endBiome.setActualBiome(biome);
|
||||
endBiome.updateActualBiomes(biomeRegistry);
|
||||
});
|
||||
|
||||
CLIENT.clear();
|
||||
|
|
|
@ -19,8 +19,8 @@ import ru.betterend.world.structures.features.StructureMegaLakeSmall;
|
|||
import ru.betterend.world.structures.features.StructureMountain;
|
||||
import ru.betterend.world.structures.features.StructurePaintedMountain;
|
||||
import ru.betterend.world.structures.piece.CavePiece;
|
||||
import ru.betterend.world.structures.piece.LakePiece;
|
||||
import ru.betterend.world.structures.piece.CrystalMountainPiece;
|
||||
import ru.betterend.world.structures.piece.LakePiece;
|
||||
import ru.betterend.world.structures.piece.NBTPiece;
|
||||
import ru.betterend.world.structures.piece.PaintedMountainPiece;
|
||||
import ru.betterend.world.structures.piece.VoxelPiece;
|
||||
|
|
|
@ -9,6 +9,7 @@ import com.google.gson.JsonArray;
|
|||
import com.google.gson.JsonObject;
|
||||
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import ru.betterend.config.Configs;
|
||||
import ru.betterend.util.JsonFactory;
|
||||
|
@ -161,10 +162,6 @@ public class EndBiome {
|
|||
return structuresFeature;
|
||||
}
|
||||
|
||||
public void setActualBiome(Biome biome) {
|
||||
this.actualBiome = biome;
|
||||
}
|
||||
|
||||
public Biome getActualBiome() {
|
||||
return this.actualBiome;
|
||||
}
|
||||
|
@ -180,4 +177,34 @@ public class EndBiome {
|
|||
public boolean hasCaves() {
|
||||
return hasCaves;
|
||||
}
|
||||
|
||||
public void updateActualBiomes(Registry<Biome> biomeRegistry) {
|
||||
subbiomes.forEach((sub) -> {
|
||||
sub.updateActualBiomes(biomeRegistry);
|
||||
});
|
||||
if (edge != null) {
|
||||
edge.updateActualBiomes(biomeRegistry);
|
||||
}
|
||||
Biome biome = biomeRegistry.get(mcID);
|
||||
this.actualBiome = biome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
EndBiome biome = (EndBiome) obj;
|
||||
return biome == null ? false : biome.mcID.equals(mcID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return mcID.hashCode();
|
||||
}
|
||||
|
||||
public List<EndBiome> subbiomes() {
|
||||
// TODO Auto-generated method stub
|
||||
return this.subbiomes;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,6 @@ public class BiomePicker {
|
|||
|
||||
public void addBiomeMutable(EndBiome biome) {
|
||||
biomes.add(biome);
|
||||
maxChance = biome.mutateGenChance(maxChance);
|
||||
}
|
||||
|
||||
public void clearMutables() {
|
||||
|
@ -49,7 +48,21 @@ public class BiomePicker {
|
|||
return immutableIDs.contains(id);
|
||||
}
|
||||
|
||||
public void removeMutableBiome(Identifier id) {
|
||||
for (int i = biomeCount; i < biomes.size(); i++) {
|
||||
EndBiome biome = biomes.get(i);
|
||||
if (biome.getID().equals(id)) {
|
||||
biomes.remove(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void rebuild() {
|
||||
maxChance = maxChanceUnmutable;
|
||||
for (int i = biomeCount; i < biomes.size(); i++) {
|
||||
maxChance = biomes.get(i).mutateGenChance(maxChance);
|
||||
}
|
||||
tree = new WeighTree(biomes);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue