Bonemeal API update and unification, sub-biome fix
This commit is contained in:
parent
d8a620c589
commit
1609b28595
9 changed files with 109 additions and 73 deletions
|
@ -8,7 +8,7 @@ yarn_mappings= 6
|
||||||
loader_version= 0.11.6
|
loader_version= 0.11.6
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version = 0.2.2
|
mod_version = 0.2.3
|
||||||
maven_group = ru.bclib
|
maven_group = ru.bclib
|
||||||
archives_base_name = bclib
|
archives_base_name = bclib
|
||||||
|
|
||||||
|
|
|
@ -15,38 +15,51 @@ public class BonemealAPI {
|
||||||
private static final Map<ResourceLocation, Map<Block, WeightedList<Block>>> LAND_GRASS_BIOMES = Maps.newHashMap();
|
private static final Map<ResourceLocation, Map<Block, WeightedList<Block>>> LAND_GRASS_BIOMES = Maps.newHashMap();
|
||||||
private static final Map<Block, WeightedList<Block>> WATER_GRASS_TYPES = Maps.newHashMap();
|
private static final Map<Block, WeightedList<Block>> WATER_GRASS_TYPES = Maps.newHashMap();
|
||||||
private static final Map<Block, WeightedList<Block>> LAND_GRASS_TYPES = Maps.newHashMap();
|
private static final Map<Block, WeightedList<Block>> LAND_GRASS_TYPES = Maps.newHashMap();
|
||||||
private static final Set<Block> SPREADABLE_BLOCKS = Sets.newHashSet();
|
private static final Map<Block, Block> SPREADABLE_BLOCKS = Maps.newHashMap();
|
||||||
|
private static final Set<Block> TERRAIN_TO_SPREAD = Sets.newHashSet();
|
||||||
|
private static final Set<Block> TERRAIN = Sets.newHashSet();
|
||||||
|
|
||||||
public static void addSpreadableBlock(Block block) {
|
public static void addSpreadableBlock(Block spreadableBlock, Block surfaceForSpread) {
|
||||||
SPREADABLE_BLOCKS.add(block);
|
SPREADABLE_BLOCKS.put(spreadableBlock, surfaceForSpread);
|
||||||
|
TERRAIN_TO_SPREAD.add(surfaceForSpread);
|
||||||
|
TERRAIN.add(surfaceForSpread);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isSpreadable(Block block) {
|
public static boolean isTerrain(Block block) {
|
||||||
return SPREADABLE_BLOCKS.contains(block);
|
return TERRAIN.contains(block);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isSpreadableTerrain(Block block) {
|
||||||
|
return TERRAIN_TO_SPREAD.contains(block);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Block getSpreadable(Block block) {
|
||||||
|
return SPREADABLE_BLOCKS.get(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addLandGrass(Block plant, Block... terrain) {
|
public static void addLandGrass(Block plant, Block... terrain) {
|
||||||
for (Block block : terrain) {
|
for (Block block : terrain) {
|
||||||
addLandGrass(block, plant, 1F);
|
addLandGrass(plant, block, 1F);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addLandGrass(ResourceLocation biome, Block plant, Block... terrain) {
|
public static void addLandGrass(ResourceLocation biome, Block plant, Block... terrain) {
|
||||||
for (Block block : terrain) {
|
for (Block block : terrain) {
|
||||||
addLandGrass(biome, block, plant, 1F);
|
addLandGrass(biome, plant, block, 1F);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addLandGrass(Block terrain, Block plant, float chance) {
|
public static void addLandGrass(Block plant, Block terrain, float chance) {
|
||||||
WeightedList<Block> list = LAND_GRASS_TYPES.get(terrain);
|
WeightedList<Block> list = LAND_GRASS_TYPES.get(terrain);
|
||||||
if (list == null) {
|
if (list == null) {
|
||||||
list = new WeightedList<Block>();
|
list = new WeightedList<Block>();
|
||||||
LAND_GRASS_TYPES.put(terrain, list);
|
LAND_GRASS_TYPES.put(terrain, list);
|
||||||
}
|
}
|
||||||
|
TERRAIN.add(terrain);
|
||||||
list.add(plant, chance);
|
list.add(plant, chance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addLandGrass(ResourceLocation biome, Block terrain, Block plant, float chance) {
|
public static void addLandGrass(ResourceLocation biome, Block plant, Block terrain, float chance) {
|
||||||
Map<Block, WeightedList<Block>> map = LAND_GRASS_BIOMES.get(biome);
|
Map<Block, WeightedList<Block>> map = LAND_GRASS_BIOMES.get(biome);
|
||||||
if (map == null) {
|
if (map == null) {
|
||||||
map = Maps.newHashMap();
|
map = Maps.newHashMap();
|
||||||
|
@ -57,31 +70,33 @@ public class BonemealAPI {
|
||||||
list = new WeightedList<Block>();
|
list = new WeightedList<Block>();
|
||||||
map.put(terrain, list);
|
map.put(terrain, list);
|
||||||
}
|
}
|
||||||
|
TERRAIN.add(terrain);
|
||||||
list.add(plant, chance);
|
list.add(plant, chance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addWaterGrass(Block plant, Block... terrain) {
|
public static void addWaterGrass(Block plant, Block... terrain) {
|
||||||
for (Block block : terrain) {
|
for (Block block : terrain) {
|
||||||
addWaterGrass(block, plant, 1F);
|
addWaterGrass(plant, block, 1F);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addWaterGrass(ResourceLocation biome, Block plant, Block... terrain) {
|
public static void addWaterGrass(ResourceLocation biome, Block plant, Block... terrain) {
|
||||||
for (Block block : terrain) {
|
for (Block block : terrain) {
|
||||||
addWaterGrass(biome, block, plant, 1F);
|
addWaterGrass(biome, plant, block, 1F);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addWaterGrass(Block terrain, Block plant, float chance) {
|
public static void addWaterGrass(Block plant, Block terrain, float chance) {
|
||||||
WeightedList<Block> list = WATER_GRASS_TYPES.get(terrain);
|
WeightedList<Block> list = WATER_GRASS_TYPES.get(terrain);
|
||||||
if (list == null) {
|
if (list == null) {
|
||||||
list = new WeightedList<Block>();
|
list = new WeightedList<Block>();
|
||||||
WATER_GRASS_TYPES.put(terrain, list);
|
WATER_GRASS_TYPES.put(terrain, list);
|
||||||
}
|
}
|
||||||
|
TERRAIN.add(terrain);
|
||||||
list.add(plant, chance);
|
list.add(plant, chance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addWaterGrass(ResourceLocation biome, Block terrain, Block plant, float chance) {
|
public static void addWaterGrass(ResourceLocation biome, Block plant, Block terrain, float chance) {
|
||||||
Map<Block, WeightedList<Block>> map = WATER_GRASS_BIOMES.get(biome);
|
Map<Block, WeightedList<Block>> map = WATER_GRASS_BIOMES.get(biome);
|
||||||
if (map == null) {
|
if (map == null) {
|
||||||
map = Maps.newHashMap();
|
map = Maps.newHashMap();
|
||||||
|
@ -92,6 +107,7 @@ public class BonemealAPI {
|
||||||
list = new WeightedList<Block>();
|
list = new WeightedList<Block>();
|
||||||
map.put(terrain, list);
|
map.put(terrain, list);
|
||||||
}
|
}
|
||||||
|
TERRAIN.add(terrain);
|
||||||
list.add(plant, chance);
|
list.add(plant, chance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,9 +25,9 @@ import ru.bclib.world.biomes.BCLBiome;
|
||||||
|
|
||||||
@Mixin(FogRenderer.class)
|
@Mixin(FogRenderer.class)
|
||||||
public class BackgroundRendererMixin {
|
public class BackgroundRendererMixin {
|
||||||
private static final MutableBlockPos BCL_LAST_POS = new MutableBlockPos(0, -100, 0);
|
private static final MutableBlockPos BCLIB_LAST_POS = new MutableBlockPos(0, -100, 0);
|
||||||
private static final MutableBlockPos BCL_MUT_POS = new MutableBlockPos();
|
private static final MutableBlockPos BCLIB_MUT_POS = new MutableBlockPos();
|
||||||
private static final float[] BCL_FOG_DENSITY = new float[8];
|
private static final float[] BCLIB_FOG_DENSITY = new float[8];
|
||||||
|
|
||||||
@Shadow
|
@Shadow
|
||||||
private static float fogRed;
|
private static float fogRed;
|
||||||
|
@ -37,7 +37,7 @@ public class BackgroundRendererMixin {
|
||||||
private static float fogBlue;
|
private static float fogBlue;
|
||||||
|
|
||||||
@Inject(method = "setupColor", at = @At("RETURN"))
|
@Inject(method = "setupColor", at = @At("RETURN"))
|
||||||
private static void bcl_onRender(Camera camera, float tickDelta, ClientLevel world, int i, float f, CallbackInfo info) {
|
private static void bclib_onRender(Camera camera, float tickDelta, ClientLevel world, int i, float f, CallbackInfo info) {
|
||||||
FogType fogType = camera.getFluidInCamera();
|
FogType fogType = camera.getFluidInCamera();
|
||||||
if (fogType != FogType.WATER && world.dimension().equals(Level.END)) {
|
if (fogType != FogType.WATER && world.dimension().equals(Level.END)) {
|
||||||
Entity entity = camera.getEntity();
|
Entity entity = camera.getEntity();
|
||||||
|
@ -59,14 +59,14 @@ public class BackgroundRendererMixin {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "setupFog", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "setupFog", at = @At("HEAD"), cancellable = true)
|
||||||
private static void bcl_fogDensity(Camera camera, FogRenderer.FogMode fogMode, float viewDistance, boolean thickFog, CallbackInfo info) {
|
private static void bclib_fogDensity(Camera camera, FogRenderer.FogMode fogMode, float viewDistance, boolean thickFog, CallbackInfo info) {
|
||||||
Entity entity = camera.getEntity();
|
Entity entity = camera.getEntity();
|
||||||
FogType fogType = camera.getFluidInCamera();
|
FogType fogType = camera.getFluidInCamera();
|
||||||
if (fogType != FogType.WATER) {
|
if (fogType != FogType.WATER) {
|
||||||
if (bcl_shouldIgnore(entity.level, (int) entity.getX(), (int) entity.getEyeY(), (int) entity.getZ())) {
|
if (bclib_shouldIgnore(entity.level, (int) entity.getX(), (int) entity.getEyeY(), (int) entity.getZ())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
float fog = bcl_getFogDensity(entity.level, entity.getX(), entity.getEyeY(), entity.getZ());
|
float fog = bclib_getFogDensity(entity.level, entity.getX(), entity.getEyeY(), entity.getZ());
|
||||||
BackgroundInfo.fogDensity = fog;
|
BackgroundInfo.fogDensity = fog;
|
||||||
float start = viewDistance * 0.75F / fog;
|
float start = viewDistance * 0.75F / fog;
|
||||||
float end = viewDistance / fog;
|
float end = viewDistance / fog;
|
||||||
|
@ -99,18 +99,18 @@ public class BackgroundRendererMixin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean bcl_shouldIgnore(Level level, int x, int y, int z) {
|
private static boolean bclib_shouldIgnore(Level level, int x, int y, int z) {
|
||||||
Biome biome = level.getBiome(BCL_MUT_POS.set(x, y, z));
|
Biome biome = level.getBiome(BCLIB_MUT_POS.set(x, y, z));
|
||||||
return BiomeAPI.getRenderBiome(biome) == BiomeAPI.EMPTY_BIOME;
|
return BiomeAPI.getRenderBiome(biome) == BiomeAPI.EMPTY_BIOME;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static float bcl_getFogDensityI(Level level, int x, int y, int z) {
|
private static float bclib_getFogDensityI(Level level, int x, int y, int z) {
|
||||||
Biome biome = level.getBiome(BCL_MUT_POS.set(x, y, z));
|
Biome biome = level.getBiome(BCLIB_MUT_POS.set(x, y, z));
|
||||||
BCLBiome renderBiome = BiomeAPI.getRenderBiome(biome);
|
BCLBiome renderBiome = BiomeAPI.getRenderBiome(biome);
|
||||||
return renderBiome.getFogDensity();
|
return renderBiome.getFogDensity();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static float bcl_getFogDensity(Level level, double x, double y, double z) {
|
private static float bclib_getFogDensity(Level level, double x, double y, double z) {
|
||||||
int x1 = (MHelper.floor(x) >> 3) << 3;
|
int x1 = (MHelper.floor(x) >> 3) << 3;
|
||||||
int y1 = (MHelper.floor(y) >> 3) << 3;
|
int y1 = (MHelper.floor(y) >> 3) << 3;
|
||||||
int z1 = (MHelper.floor(z) >> 3) << 3;
|
int z1 = (MHelper.floor(z) >> 3) << 3;
|
||||||
|
@ -118,25 +118,25 @@ public class BackgroundRendererMixin {
|
||||||
float dy = (float) (y - y1) / 8F;
|
float dy = (float) (y - y1) / 8F;
|
||||||
float dz = (float) (z - z1) / 8F;
|
float dz = (float) (z - z1) / 8F;
|
||||||
|
|
||||||
if (BCL_LAST_POS.getX() != x1 || BCL_LAST_POS.getY() != y1 || BCL_LAST_POS.getZ() != z1) {
|
if (BCLIB_LAST_POS.getX() != x1 || BCLIB_LAST_POS.getY() != y1 || BCLIB_LAST_POS.getZ() != z1) {
|
||||||
int x2 = x1 + 8;
|
int x2 = x1 + 8;
|
||||||
int y2 = y1 + 8;
|
int y2 = y1 + 8;
|
||||||
int z2 = z1 + 8;
|
int z2 = z1 + 8;
|
||||||
BCL_LAST_POS.set(x1, y1, z1);
|
BCLIB_LAST_POS.set(x1, y1, z1);
|
||||||
BCL_FOG_DENSITY[0] = bcl_getFogDensityI(level, x1, y1, z1);
|
BCLIB_FOG_DENSITY[0] = bclib_getFogDensityI(level, x1, y1, z1);
|
||||||
BCL_FOG_DENSITY[1] = bcl_getFogDensityI(level, x2, y1, z1);
|
BCLIB_FOG_DENSITY[1] = bclib_getFogDensityI(level, x2, y1, z1);
|
||||||
BCL_FOG_DENSITY[2] = bcl_getFogDensityI(level, x1, y2, z1);
|
BCLIB_FOG_DENSITY[2] = bclib_getFogDensityI(level, x1, y2, z1);
|
||||||
BCL_FOG_DENSITY[3] = bcl_getFogDensityI(level, x2, y2, z1);
|
BCLIB_FOG_DENSITY[3] = bclib_getFogDensityI(level, x2, y2, z1);
|
||||||
BCL_FOG_DENSITY[4] = bcl_getFogDensityI(level, x1, y1, z2);
|
BCLIB_FOG_DENSITY[4] = bclib_getFogDensityI(level, x1, y1, z2);
|
||||||
BCL_FOG_DENSITY[5] = bcl_getFogDensityI(level, x2, y1, z2);
|
BCLIB_FOG_DENSITY[5] = bclib_getFogDensityI(level, x2, y1, z2);
|
||||||
BCL_FOG_DENSITY[6] = bcl_getFogDensityI(level, x1, y2, z2);
|
BCLIB_FOG_DENSITY[6] = bclib_getFogDensityI(level, x1, y2, z2);
|
||||||
BCL_FOG_DENSITY[7] = bcl_getFogDensityI(level, x2, y2, z2);
|
BCLIB_FOG_DENSITY[7] = bclib_getFogDensityI(level, x2, y2, z2);
|
||||||
}
|
}
|
||||||
|
|
||||||
float a = Mth.lerp(dx, BCL_FOG_DENSITY[0], BCL_FOG_DENSITY[1]);
|
float a = Mth.lerp(dx, BCLIB_FOG_DENSITY[0], BCLIB_FOG_DENSITY[1]);
|
||||||
float b = Mth.lerp(dx, BCL_FOG_DENSITY[2], BCL_FOG_DENSITY[3]);
|
float b = Mth.lerp(dx, BCLIB_FOG_DENSITY[2], BCLIB_FOG_DENSITY[3]);
|
||||||
float c = Mth.lerp(dx, BCL_FOG_DENSITY[4], BCL_FOG_DENSITY[5]);
|
float c = Mth.lerp(dx, BCLIB_FOG_DENSITY[4], BCLIB_FOG_DENSITY[5]);
|
||||||
float d = Mth.lerp(dx, BCL_FOG_DENSITY[6], BCL_FOG_DENSITY[7]);
|
float d = Mth.lerp(dx, BCLIB_FOG_DENSITY[6], BCLIB_FOG_DENSITY[7]);
|
||||||
|
|
||||||
a = Mth.lerp(dy, a, b);
|
a = Mth.lerp(dy, a, b);
|
||||||
b = Mth.lerp(dy, c, d);
|
b = Mth.lerp(dy, c, d);
|
||||||
|
|
|
@ -11,6 +11,7 @@ import net.minecraft.world.level.biome.Biome.BiomeCategory;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import net.minecraft.world.level.block.state.properties.Property;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
@ -21,6 +22,8 @@ import ru.bclib.api.TagAPI;
|
||||||
import ru.bclib.util.BlocksHelper;
|
import ru.bclib.util.BlocksHelper;
|
||||||
import ru.bclib.util.MHelper;
|
import ru.bclib.util.MHelper;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
@Mixin(BoneMealItem.class)
|
@Mixin(BoneMealItem.class)
|
||||||
public class BoneMealItemMixin {
|
public class BoneMealItemMixin {
|
||||||
private static final MutableBlockPos bclib_BLOCK_POS = new MutableBlockPos();
|
private static final MutableBlockPos bclib_BLOCK_POS = new MutableBlockPos();
|
||||||
|
@ -31,24 +34,23 @@ public class BoneMealItemMixin {
|
||||||
BlockPos blockPos = context.getClickedPos();
|
BlockPos blockPos = context.getClickedPos();
|
||||||
if (!world.isClientSide) {
|
if (!world.isClientSide) {
|
||||||
BlockPos offseted = blockPos.relative(context.getClickedFace());
|
BlockPos offseted = blockPos.relative(context.getClickedFace());
|
||||||
boolean endBiome = world.getBiome(offseted).getBiomeCategory() == BiomeCategory.THEEND;
|
if (BonemealAPI.isTerrain(world.getBlockState(blockPos).getBlock())) {
|
||||||
|
|
||||||
if (world.getBlockState(blockPos).is(TagAPI.END_GROUND)) {
|
|
||||||
boolean consume = false;
|
boolean consume = false;
|
||||||
if (world.getBlockState(blockPos).is(Blocks.END_STONE)) {
|
if (BonemealAPI.isSpreadableTerrain(world.getBlockState(blockPos).getBlock())) {
|
||||||
BlockState nylium = bclib_getNylium(world, blockPos);
|
BlockState terrain = bclib_getSpreadable(world, blockPos);
|
||||||
if (nylium != null) {
|
if (terrain != null) {
|
||||||
BlocksHelper.setWithoutUpdate(world, blockPos, nylium);
|
BlocksHelper.setWithoutUpdate(world, blockPos, terrain);
|
||||||
consume = true;
|
consume = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!world.getFluidState(offseted).isEmpty() && endBiome) {
|
BlockState state = world.getBlockState(offseted);
|
||||||
if (world.getBlockState(offseted).getBlock().equals(Blocks.WATER)) {
|
if (!state.getFluidState().isEmpty()) {
|
||||||
|
if (state.is(Blocks.WATER)) {
|
||||||
consume = bclib_growWaterGrass(world, blockPos);
|
consume = bclib_growWaterGrass(world, blockPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else if (state.isAir()) {
|
||||||
consume = bclib_growLandGrass(world, blockPos);
|
consume = bclib_growLandGrass(world, blockPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,12 +63,6 @@ public class BoneMealItemMixin {
|
||||||
info.cancel();
|
info.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!world.getFluidState(offseted).isEmpty() && endBiome) {
|
|
||||||
if (world.getBlockState(offseted).getBlock().equals(Blocks.WATER)) {
|
|
||||||
info.setReturnValue(InteractionResult.FAIL);
|
|
||||||
info.cancel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,15 +130,38 @@ public class BoneMealItemMixin {
|
||||||
return block == null ? null : block.defaultBlockState();
|
return block == null ? null : block.defaultBlockState();
|
||||||
}
|
}
|
||||||
|
|
||||||
private BlockState bclib_getNylium(Level world, BlockPos pos) {
|
private BlockState bclib_getSpreadable(Level world, BlockPos pos) {
|
||||||
Vec3i[] offsets = MHelper.getOffsets(world.getRandom());
|
Vec3i[] offsets = MHelper.getOffsets(world.getRandom());
|
||||||
|
BlockState center = world.getBlockState(pos);
|
||||||
for (Vec3i dir : offsets) {
|
for (Vec3i dir : offsets) {
|
||||||
BlockPos p = pos.offset(dir);
|
BlockPos p = pos.offset(dir);
|
||||||
BlockState state = world.getBlockState(p);
|
BlockState state = world.getBlockState(p);
|
||||||
if (BonemealAPI.isSpreadable(state.getBlock())) {
|
Block terrain = BonemealAPI.getSpreadable(state.getBlock());
|
||||||
|
if (center.is(terrain)) {
|
||||||
|
if (haveSameProperties(state, center)) {
|
||||||
|
for (Property property: center.getProperties()) {
|
||||||
|
state = state.setValue(property, center.getValue(property));
|
||||||
|
}
|
||||||
|
}
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean haveSameProperties(BlockState state1, BlockState state2) {
|
||||||
|
Property<?>[] properties1 = state1.getProperties().toArray(new Property[0]);
|
||||||
|
Property<?>[] properties2 = state2.getProperties().toArray(new Property[0]);
|
||||||
|
if (properties1.length != properties2.length) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < properties1.length; i++) {
|
||||||
|
String name1 = properties1[i].getName();
|
||||||
|
String name2 = properties2[i].getName();
|
||||||
|
if (!name1.equals(name2)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -7,5 +7,5 @@ import org.spongepowered.asm.mixin.gen.Accessor;
|
||||||
@Mixin(targets = "net.minecraft.data.worldgen.Features$Decorators")
|
@Mixin(targets = "net.minecraft.data.worldgen.Features$Decorators")
|
||||||
public interface FeatureDecoratorsAccessor {
|
public interface FeatureDecoratorsAccessor {
|
||||||
@Accessor("HEIGHTMAP_SQUARE")
|
@Accessor("HEIGHTMAP_SQUARE")
|
||||||
ConfiguredDecorator<?> bcl_getHeightmapSquare();
|
ConfiguredDecorator<?> bclib_getHeightmapSquare();
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,20 +35,20 @@ public class MinecraftServerMixin {
|
||||||
protected WorldData worldData;
|
protected WorldData worldData;
|
||||||
|
|
||||||
@Inject(method = "reloadResources", at = @At(value = "RETURN"), cancellable = true)
|
@Inject(method = "reloadResources", at = @At(value = "RETURN"), cancellable = true)
|
||||||
private void bcl_reloadResources(Collection<String> collection, CallbackInfoReturnable<CompletableFuture<Void>> info) {
|
private void bclib_reloadResources(Collection<String> collection, CallbackInfoReturnable<CompletableFuture<Void>> info) {
|
||||||
bcl_injectRecipes();
|
bclib_injectRecipes();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "loadLevel", at = @At(value = "RETURN"), cancellable = true)
|
@Inject(method = "loadLevel", at = @At(value = "RETURN"), cancellable = true)
|
||||||
private void bcl_loadLevel(CallbackInfo info) {
|
private void bclib_loadLevel(CallbackInfo info) {
|
||||||
bcl_injectRecipes();
|
bclib_injectRecipes();
|
||||||
BiomeAPI.initRegistry(MinecraftServer.class.cast(this));
|
BiomeAPI.initRegistry(MinecraftServer.class.cast(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void bcl_injectRecipes() {
|
private void bclib_injectRecipes() {
|
||||||
if (FabricLoader.getInstance().isModLoaded("kubejs")) {
|
if (FabricLoader.getInstance().isModLoaded("kubejs")) {
|
||||||
RecipeManagerAccessor accessor = (RecipeManagerAccessor) resources.getRecipeManager();
|
RecipeManagerAccessor accessor = (RecipeManagerAccessor) resources.getRecipeManager();
|
||||||
accessor.bcl_setRecipes(BCLRecipeManager.getMap(accessor.bcl_getRecipes()));
|
accessor.bclib_setRecipes(BCLRecipeManager.getMap(accessor.bclib_getRecipes()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,8 @@ import java.util.Map;
|
||||||
@Mixin(RecipeManager.class)
|
@Mixin(RecipeManager.class)
|
||||||
public interface RecipeManagerAccessor {
|
public interface RecipeManagerAccessor {
|
||||||
@Accessor("recipes")
|
@Accessor("recipes")
|
||||||
Map<RecipeType<?>, Map<ResourceLocation, Recipe<?>>> bcl_getRecipes();
|
Map<RecipeType<?>, Map<ResourceLocation, Recipe<?>>> bclib_getRecipes();
|
||||||
|
|
||||||
@Accessor("recipes")
|
@Accessor("recipes")
|
||||||
void bcl_setRecipes(Map<RecipeType<?>, Map<ResourceLocation, Recipe<?>>> recipes);
|
void bclib_setRecipes(Map<RecipeType<?>, Map<ResourceLocation, Recipe<?>>> recipes);
|
||||||
}
|
}
|
|
@ -27,21 +27,21 @@ import java.util.function.Supplier;
|
||||||
|
|
||||||
@Mixin(ServerLevel.class)
|
@Mixin(ServerLevel.class)
|
||||||
public abstract class ServerLevelMixin extends Level {
|
public abstract class ServerLevelMixin extends Level {
|
||||||
private static String bcl_lastWorld = null;
|
private static String bclib_lastWorld = null;
|
||||||
|
|
||||||
protected ServerLevelMixin(WritableLevelData writableLevelData, ResourceKey<Level> resourceKey, DimensionType dimensionType, Supplier<ProfilerFiller> supplier, boolean bl, boolean bl2, long l) {
|
protected ServerLevelMixin(WritableLevelData writableLevelData, ResourceKey<Level> resourceKey, DimensionType dimensionType, Supplier<ProfilerFiller> supplier, boolean bl, boolean bl2, long l) {
|
||||||
super(writableLevelData, resourceKey, dimensionType, supplier, bl, bl2, l);
|
super(writableLevelData, resourceKey, dimensionType, supplier, bl, bl2, l);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "<init>*", at = @At("TAIL"))
|
@Inject(method = "<init>*", at = @At("TAIL"))
|
||||||
private void bcl_onServerWorldInit(MinecraftServer server, Executor workerExecutor, LevelStorageSource.LevelStorageAccess session, ServerLevelData properties, ResourceKey<Level> registryKey, DimensionType dimensionType, ChunkProgressListener worldGenerationProgressListener, ChunkGenerator chunkGenerator, boolean debugWorld, long l, List<CustomSpawner> list, boolean bl, CallbackInfo info) {
|
private void bclib_onServerWorldInit(MinecraftServer server, Executor workerExecutor, LevelStorageSource.LevelStorageAccess session, ServerLevelData properties, ResourceKey<Level> registryKey, DimensionType dimensionType, ChunkProgressListener worldGenerationProgressListener, ChunkGenerator chunkGenerator, boolean debugWorld, long l, List<CustomSpawner> list, boolean bl, CallbackInfo info) {
|
||||||
BiomeAPI.initRegistry(server);
|
BiomeAPI.initRegistry(server);
|
||||||
|
|
||||||
if (bcl_lastWorld != null && bcl_lastWorld.equals(session.getLevelId())) {
|
if (bclib_lastWorld != null && bclib_lastWorld.equals(session.getLevelId())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bcl_lastWorld = session.getLevelId();
|
bclib_lastWorld = session.getLevelId();
|
||||||
|
|
||||||
ServerLevel world = ServerLevel.class.cast(this);
|
ServerLevel world = ServerLevel.class.cast(this);
|
||||||
File dir = session.getDimensionPath(world.dimension());
|
File dir = session.getDimensionPath(world.dimension());
|
||||||
|
|
|
@ -47,6 +47,7 @@ public class BCLBiome {
|
||||||
this.genChance = definition.getGenChance();
|
this.genChance = definition.getGenChance();
|
||||||
this.fogDensity = definition.getFodDensity();
|
this.fogDensity = definition.getFodDensity();
|
||||||
this.customData = definition.getCustomData();
|
this.customData = definition.getCustomData();
|
||||||
|
subbiomes.add(this, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BCLBiome(ResourceLocation id, Biome biome, float fogDensity, float genChance) {
|
public BCLBiome(ResourceLocation id, Biome biome, float fogDensity, float genChance) {
|
||||||
|
@ -56,6 +57,7 @@ public class BCLBiome {
|
||||||
this.fogDensity = fogDensity;
|
this.fogDensity = fogDensity;
|
||||||
this.readStructureList();
|
this.readStructureList();
|
||||||
this.customData = Maps.newHashMap();
|
this.customData = Maps.newHashMap();
|
||||||
|
subbiomes.add(this, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BCLBiome getEdge() {
|
public BCLBiome getEdge() {
|
||||||
|
@ -85,8 +87,7 @@ public class BCLBiome {
|
||||||
}
|
}
|
||||||
|
|
||||||
public BCLBiome getSubBiome(Random random) {
|
public BCLBiome getSubBiome(Random random) {
|
||||||
BCLBiome biome = subbiomes.get(random);
|
return subbiomes.get(random);
|
||||||
return biome == null ? this : biome;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public BCLBiome getParentBiome() {
|
public BCLBiome getParentBiome() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue