Some more Changes for 1.18.2
This commit is contained in:
parent
2dbbfe04d8
commit
305ac05ac1
23 changed files with 148 additions and 186 deletions
|
@ -646,14 +646,14 @@ public class BiomeAPI {
|
|||
private static void addBiomeFeature(Biome biome, Decoration step, List<PlacedFeature> featureList) {
|
||||
BiomeGenerationSettingsAccessor accessor = (BiomeGenerationSettingsAccessor) biome.getGenerationSettings();
|
||||
List<List<Supplier<PlacedFeature>>> allFeatures = CollectionsUtil.getMutable(accessor.bclib_getFeatures());
|
||||
Set<PlacedFeature> set = CollectionsUtil.getMutable(accessor.bclib_getFeatureSet());
|
||||
Set<PlacedFeature> set = CollectionsUtil.getMutable(accessor.bclib_getFeatureSet().get());
|
||||
List<Supplier<PlacedFeature>> features = getFeaturesList(allFeatures, step);
|
||||
for (var feature : featureList) {
|
||||
features.add(() -> feature);
|
||||
set.add(feature);
|
||||
}
|
||||
accessor.bclib_setFeatures(allFeatures);
|
||||
accessor.bclib_setFeatureSet(set);
|
||||
accessor.bclib_setFeatureSet(()-> set);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -667,7 +667,7 @@ public class BiomeAPI {
|
|||
private static void addStepFeaturesToBiome(Biome biome, Map<Decoration, List<Supplier<PlacedFeature>>> featureMap) {
|
||||
BiomeGenerationSettingsAccessor accessor = (BiomeGenerationSettingsAccessor) biome.getGenerationSettings();
|
||||
List<List<Supplier<PlacedFeature>>> allFeatures = CollectionsUtil.getMutable(accessor.bclib_getFeatures());
|
||||
Set<PlacedFeature> set = CollectionsUtil.getMutable(accessor.bclib_getFeatureSet());
|
||||
Set<PlacedFeature> set = CollectionsUtil.getMutable(accessor.bclib_getFeatureSet().get());
|
||||
|
||||
for (Decoration step: featureMap.keySet()) {
|
||||
List<Supplier<PlacedFeature>> features = getFeaturesList(allFeatures, step);
|
||||
|
@ -679,7 +679,7 @@ public class BiomeAPI {
|
|||
}
|
||||
}
|
||||
accessor.bclib_setFeatures(allFeatures);
|
||||
accessor.bclib_setFeatureSet(set);
|
||||
accessor.bclib_setFeatureSet(() -> set);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -752,11 +752,11 @@ public class BiomeAPI {
|
|||
/**
|
||||
* Get biome surface block. Can be used to get terrain material for features or other things.
|
||||
* @param pos {@link BlockPos} position to get block.
|
||||
* @param biome {@link Biome} to get block from.
|
||||
* @param biome {@link Holder<Biome>} to get block from.
|
||||
* @param level {@link ServerLevel} current server level.
|
||||
* @return {@link BlockState} with the biome surface or AIR if it fails.
|
||||
*/
|
||||
public static BlockState getBiomeSurfaceBlock(BlockPos pos, Biome biome, ServerLevel level) {
|
||||
public static BlockState getBiomeSurfaceBlock(BlockPos pos, Holder<Biome> biome, ServerLevel level) {
|
||||
ChunkGenerator generator = level.getChunkSource().getGenerator();
|
||||
if (generator instanceof NoiseBasedChunkGenerator) {
|
||||
SurfaceProvider provider = SurfaceProvider.class.cast(generator);
|
||||
|
|
|
@ -242,7 +242,15 @@ public class TagAPI {
|
|||
}
|
||||
}
|
||||
|
||||
public static boolean isToolWithMineableTag(ItemStack stack, TagKey<Block> tag){
|
||||
return isToolWithUntypedMineableTag(stack, tag.location());
|
||||
}
|
||||
|
||||
public static boolean isToolWithMineableTag(ItemStack stack, TagLocation<Block> tag){
|
||||
return isToolWithUntypedMineableTag(stack, tag);
|
||||
}
|
||||
|
||||
private static boolean isToolWithUntypedMineableTag(ItemStack stack, ResourceLocation tag){
|
||||
if (stack.getItem() instanceof DiggerItemAccessor dig){
|
||||
return dig.bclib_getBlockTag().location().equals(tag);
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
|
|||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.Tag;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
@ -106,39 +105,39 @@ public abstract class ComplexMaterial {
|
|||
|
||||
/**
|
||||
* Adds custom block tag for this {@link ComplexMaterial}, tag can be created with {@link TagAPI} or you can use one of already created tags.
|
||||
* @param tag {@link Tag.Named} for {@link Block}
|
||||
* @param tag {@link TagKey} for {@link Block}
|
||||
*/
|
||||
protected void addBlockTag(Tag.Named<Block> tag) {
|
||||
String key = tag.getName().getPath().replace(getBaseName() + "_", "");
|
||||
protected void addBlockTag(TagKey<Block> tag) {
|
||||
String key = tag.location().getPath().replace(getBaseName() + "_", "");
|
||||
blockTags.put(key, tag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds custom iten tag for this {@link ComplexMaterial}, tag can be created with {@link TagAPI} or you can use one of already created tags.
|
||||
* @param tag {@link Tag.Named} for {@link Item}
|
||||
* Adds custom item tag for this {@link ComplexMaterial}, tag can be created with {@link TagAPI} or you can use one of already created tags.
|
||||
* @param tag {@link TagKey} for {@link Item}
|
||||
*/
|
||||
protected void addItemTag(Tag.Named<Item> tag) {
|
||||
String key = tag.getName().getPath().replace(getBaseName() + "_", "");
|
||||
protected void addItemTag(TagKey<Item> tag) {
|
||||
String key = tag.location().getPath().replace(getBaseName() + "_", "");
|
||||
itemTags.put(key, tag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom {@link Block} {@link Tag.Named} from this {@link ComplexMaterial}.
|
||||
* Get custom {@link Block} {@link TagKey} from this {@link ComplexMaterial}.
|
||||
* @param key {@link String} tag name (path of its {@link ResourceLocation}), for inner tags created inside material its tag suffix.
|
||||
* @return {@link Tag.Named} for {@link Block} or {@code null} if nothing is stored.
|
||||
* @return {@link TagKey} for {@link Block} or {@code null} if nothing is stored.
|
||||
*/
|
||||
@Nullable
|
||||
public Tag.Named<Block> getBlockTag(String key) {
|
||||
public TagKey<Block> getBlockTag(String key) {
|
||||
return blockTags.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom {@link Item} {@link Tag.Named} from this {@link ComplexMaterial}.
|
||||
* Get custom {@link Item} {@link TagKey} from this {@link ComplexMaterial}.
|
||||
* @param key {@link String} tag name (path of its {@link ResourceLocation}), for inner tags created inside material its tag suffix.
|
||||
* @return {@link Tag.Named} for {@link Item} or {@code null} if nothing is stored.
|
||||
* @return {@link TagKey} for {@link Item} or {@code null} if nothing is stored.
|
||||
*/
|
||||
@Nullable
|
||||
public Tag.Named<Item> getItemTag(String key) {
|
||||
public TagKey<Item> getItemTag(String key) {
|
||||
return itemTags.get(key);
|
||||
}
|
||||
|
||||
|
|
|
@ -100,8 +100,8 @@ public class WoodenComplexMaterial extends ComplexMaterial {
|
|||
}
|
||||
|
||||
final protected void initBase(FabricBlockSettings blockSettings, FabricItemSettings itemSettings) {
|
||||
TagLocation<Block> tagBlockLog = new TagLocation<>(getBlockTag(TAG_LOGS).getName());
|
||||
TagLocation<Item> tagItemLog = new TagLocation<>(getItemTag(TAG_LOGS).getName());
|
||||
TagLocation<Block> tagBlockLog = TagLocation.of(getBlockTag(TAG_LOGS));
|
||||
TagLocation<Item> tagItemLog = TagLocation.of(getItemTag(TAG_LOGS));
|
||||
|
||||
addBlockEntry(
|
||||
new BlockEntry(BLOCK_STRIPPED_LOG, (complexMaterial, settings) -> new BaseRotatedPillarBlock(settings))
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
package ru.bclib.interfaces;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public interface SurfaceProvider {
|
||||
public BlockState bclib_getSurface(BlockPos pos, Biome biome, ServerLevel level);
|
||||
public BlockState bclib_getSurface(BlockPos pos, Holder<Biome> biome, ServerLevel level);
|
||||
}
|
||||
|
|
|
@ -2,33 +2,19 @@ package ru.bclib.items.tool;
|
|||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool;
|
||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.Tag;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.item.AxeItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Tier;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import ru.bclib.client.models.ModelsHelper;
|
||||
import ru.bclib.interfaces.ItemModelProvider;
|
||||
|
||||
public class BaseAxeItem extends AxeItem implements DynamicAttributeTool, ItemModelProvider {
|
||||
//TODO: 1.18.2 See if mining speed is still ok.
|
||||
public class BaseAxeItem extends AxeItem implements ItemModelProvider {
|
||||
public BaseAxeItem(Tier material, float attackDamage, float attackSpeed, Properties settings) {
|
||||
super(material, attackDamage, attackSpeed, settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMiningLevel(Tag<Item> tag, BlockState state, ItemStack stack, LivingEntity user) {
|
||||
if (tag.equals(FabricToolTags.AXES)) {
|
||||
return this.getTier().getLevel();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public BlockModel getItemModel(ResourceLocation resourceLocation) {
|
||||
|
|
|
@ -2,44 +2,19 @@ package ru.bclib.items.tool;
|
|||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool;
|
||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||
import net.fabricmc.fabric.impl.tool.attribute.ToolManagerImpl;
|
||||
import net.fabricmc.fabric.impl.tool.attribute.ToolManagerImpl.Entry;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.Tag;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.PickaxeItem;
|
||||
import net.minecraft.world.item.Tier;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import ru.bclib.client.models.ModelsHelper;
|
||||
import ru.bclib.interfaces.ItemModelProvider;
|
||||
|
||||
public class BasePickaxeItem extends PickaxeItem implements DynamicAttributeTool, ItemModelProvider {
|
||||
//TODO: 1.18.2 See if mining speed is still ok.
|
||||
public class BasePickaxeItem extends PickaxeItem implements ItemModelProvider {
|
||||
public BasePickaxeItem(Tier material, int attackDamage, float attackSpeed, Properties settings) {
|
||||
super(material, attackDamage, attackSpeed, settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMiningLevel(Tag<Item> tag, BlockState state, ItemStack stack, LivingEntity user) {
|
||||
if (tag.equals(FabricToolTags.PICKAXES)) {
|
||||
return getTier().getLevel();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDestroySpeed(ItemStack stack, BlockState state) {
|
||||
Entry entry = ToolManagerImpl.entryNullable(state.getBlock());
|
||||
return (entry != null && entry.getMiningLevel(FabricToolTags.PICKAXES) >= 0) ? speed : super.getDestroySpeed(
|
||||
stack,
|
||||
state
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public BlockModel getItemModel(ResourceLocation resourceLocation) {
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
package ru.bclib.items.tool;
|
||||
|
||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||
|
||||
import net.fabricmc.fabric.api.mininglevel.v1.FabricMineableTags;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.ShearsItem;
|
||||
import ru.bclib.api.tag.CommonItemTags;
|
||||
import ru.bclib.api.tag.TagAPI;
|
||||
|
||||
public class BaseShearsItem extends ShearsItem {
|
||||
public BaseShearsItem(Properties properties) {
|
||||
|
@ -13,12 +15,13 @@ public class BaseShearsItem extends ShearsItem {
|
|||
}
|
||||
|
||||
public static boolean isShear(ItemStack tool){
|
||||
return tool.is(Items.SHEARS) | tool.is(CommonItemTags.SHEARS) || tool.is(FabricToolTags.SHEARS);
|
||||
return tool.is(Items.SHEARS) | tool.is(CommonItemTags.SHEARS) || TagAPI.isToolWithMineableTag(tool, FabricMineableTags.SHEARS_MINEABLE);
|
||||
}
|
||||
|
||||
public static boolean isShear(ItemStack itemStack, Item item){
|
||||
if (item == Items.SHEARS){
|
||||
return itemStack.is(item) | itemStack.is(CommonItemTags.SHEARS) || itemStack.is(FabricToolTags.SHEARS);
|
||||
//TODO: 1.18.2 see if removing SHEARS_MINEABLE causes any problems... It should not, since it is a Block-Tag
|
||||
return itemStack.is(item) | itemStack.is(CommonItemTags.SHEARS);
|
||||
} else {
|
||||
return itemStack.is(item);
|
||||
}
|
||||
|
|
|
@ -2,44 +2,19 @@ package ru.bclib.items.tool;
|
|||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool;
|
||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||
import net.fabricmc.fabric.impl.tool.attribute.ToolManagerImpl;
|
||||
import net.fabricmc.fabric.impl.tool.attribute.ToolManagerImpl.Entry;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.Tag;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.ShovelItem;
|
||||
import net.minecraft.world.item.Tier;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import ru.bclib.client.models.ModelsHelper;
|
||||
import ru.bclib.interfaces.ItemModelProvider;
|
||||
|
||||
public class BaseShovelItem extends ShovelItem implements DynamicAttributeTool, ItemModelProvider {
|
||||
//TODO: 1.18.2 See if mining speed is still ok.
|
||||
public class BaseShovelItem extends ShovelItem implements ItemModelProvider {
|
||||
public BaseShovelItem(Tier material, float attackDamage, float attackSpeed, Properties settings) {
|
||||
super(material, attackDamage, attackSpeed, settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMiningLevel(Tag<Item> tag, BlockState state, ItemStack stack, LivingEntity user) {
|
||||
if (tag.equals(FabricToolTags.SHOVELS)) {
|
||||
return this.getTier().getLevel();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDestroySpeed(ItemStack stack, BlockState state) {
|
||||
Entry entry = ToolManagerImpl.entryNullable(state.getBlock());
|
||||
return (entry != null && entry.getMiningLevel(FabricToolTags.SHOVELS) >= 0) ? speed : super.getDestroySpeed(
|
||||
stack,
|
||||
state
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public BlockModel getItemModel(ResourceLocation resourceLocation) {
|
||||
|
|
|
@ -2,7 +2,6 @@ package ru.bclib.items.tool;
|
|||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.SwordItem;
|
||||
|
@ -10,7 +9,7 @@ import net.minecraft.world.item.Tier;
|
|||
import ru.bclib.client.models.ModelsHelper;
|
||||
import ru.bclib.interfaces.ItemModelProvider;
|
||||
|
||||
public class BaseSwordItem extends SwordItem implements DynamicAttributeTool, ItemModelProvider {
|
||||
public class BaseSwordItem extends SwordItem implements ItemModelProvider {
|
||||
public BaseSwordItem(Tier material, int attackDamage, float attackSpeed, Properties settings) {
|
||||
super(material, attackDamage, attackSpeed, settings);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package ru.bclib.mixin.client;
|
||||
|
||||
import com.mojang.datafixers.util.Function4;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.Minecraft.ExperimentalDialogType;
|
||||
import net.minecraft.client.color.block.BlockColors;
|
||||
|
@ -8,14 +7,11 @@ import net.minecraft.client.color.item.ItemColors;
|
|||
import net.minecraft.client.main.GameConfig;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.core.RegistryAccess.RegistryHolder;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.world.level.DataPackConfig;
|
||||
import net.minecraft.server.WorldStem;
|
||||
import net.minecraft.world.level.LevelSettings;
|
||||
import net.minecraft.world.level.levelgen.WorldGenSettings;
|
||||
import net.minecraft.world.level.storage.LevelStorageSource;
|
||||
import net.minecraft.world.level.storage.LevelStorageSource.LevelStorageAccess;
|
||||
import net.minecraft.world.level.storage.WorldData;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
@ -44,16 +40,14 @@ public abstract class MinecraftMixin {
|
|||
@Inject(method = "<init>*", at = @At("TAIL"))
|
||||
private void bclib_onMCInit(GameConfig args, CallbackInfo info) {
|
||||
Registry.BLOCK.forEach(block -> {
|
||||
if (block instanceof CustomColorProvider) {
|
||||
CustomColorProvider provider = (CustomColorProvider) block;
|
||||
if (block instanceof CustomColorProvider provider) {
|
||||
blockColors.register(provider.getProvider(), block);
|
||||
itemColors.register(provider.getItemProvider(), block.asItem());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Shadow
|
||||
protected abstract void doLoadLevel(String string, RegistryHolder registryHolder, Function<LevelStorageAccess, DataPackConfig> function, Function4<LevelStorageAccess, RegistryHolder, ResourceManager, DataPackConfig, WorldData> function4, boolean bl, ExperimentalDialogType experimentalDialogType);
|
||||
@Shadow protected abstract void doLoadLevel(String string, Function<LevelStorageAccess, WorldStem.DataPackConfigSupplier> function, Function<LevelStorageAccess, WorldStem.WorldDataSupplier> function2, boolean bl, ExperimentalDialogType experimentalDialogType);
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
|
@ -66,7 +60,7 @@ public abstract class MinecraftMixin {
|
|||
|
||||
if (DataFixerAPI.fixData(this.levelSource, levelID, true, (appliedFixes) -> {
|
||||
LifeCycleAPI._runBeforeLevelLoad();
|
||||
this.doLoadLevel(levelID, RegistryAccess.builtin(), Minecraft::loadDataPacks, Minecraft::loadWorldData, false, appliedFixes ? ExperimentalDialogType.NONE : ExperimentalDialogType.BACKUP);
|
||||
this.doLoadLevel(levelID, WorldStem.DataPackConfigSupplier::loadFromWorld, WorldStem.WorldDataSupplier::loadFromWorld, false, appliedFixes ? ExperimentalDialogType.NONE : ExperimentalDialogType.BACKUP);
|
||||
})) {
|
||||
//cancle call when fix-screen is presented
|
||||
ci.cancel();
|
||||
|
@ -74,7 +68,7 @@ public abstract class MinecraftMixin {
|
|||
else {
|
||||
LifeCycleAPI._runBeforeLevelLoad();
|
||||
if (Configs.CLIENT_CONFIG.suppressExperimentalDialog()) {
|
||||
this.doLoadLevel(levelID, RegistryAccess.builtin(), Minecraft::loadDataPacks, Minecraft::loadWorldData, false, ExperimentalDialogType.NONE);
|
||||
this.doLoadLevel(levelID, WorldStem.DataPackConfigSupplier::loadFromWorld, WorldStem.WorldDataSupplier::loadFromWorld, false, ExperimentalDialogType.NONE);
|
||||
//cancle call as we manually start the level load here
|
||||
ci.cancel();
|
||||
}
|
||||
|
@ -82,7 +76,7 @@ public abstract class MinecraftMixin {
|
|||
}
|
||||
|
||||
@Inject(method = "createLevel", at = @At("HEAD"))
|
||||
private void bclib_initPatchData(String levelID, LevelSettings levelSettings, RegistryHolder registryHolder, WorldGenSettings worldGenSettings, CallbackInfo ci) {
|
||||
private void bclib_initPatchData(String levelID, LevelSettings levelSettings, RegistryAccess registryAccess, WorldGenSettings worldGenSettings, CallbackInfo ci) {
|
||||
DataExchangeAPI.prepareServerside();
|
||||
BiomeAPI.prepareNewLevel();
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ import ru.bclib.api.biomes.BiomeAPI;
|
|||
@Mixin(WorldPreset.class)
|
||||
public class WorldPresetMixin {
|
||||
@Inject(method = "create", at = @At("HEAD"))
|
||||
private void bclib_create(RegistryAccess.RegistryHolder registryHolder, long l, boolean bl, boolean bl2, CallbackInfoReturnable<WorldGenSettings> info) {
|
||||
BiomeAPI.initRegistry(registryHolder.registryOrThrow(Registry.BIOME_REGISTRY));
|
||||
private void bclib_create(RegistryAccess registryAccess, long l, boolean bl, boolean bl2, CallbackInfoReturnable<WorldGenSettings> info) {
|
||||
BiomeAPI.initRegistry(registryAccess.registryOrThrow(Registry.BIOME_REGISTRY));
|
||||
}
|
||||
}
|
||||
|
|
13
src/main/java/ru/bclib/mixin/common/BiomeAccessor.java
Normal file
13
src/main/java/ru/bclib/mixin/common/BiomeAccessor.java
Normal file
|
@ -0,0 +1,13 @@
|
|||
package ru.bclib.mixin.common;
|
||||
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Mutable;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(Biome.class)
|
||||
public interface BiomeAccessor {
|
||||
@Accessor("biomeCategory")
|
||||
@Mutable
|
||||
Biome.BiomeCategory bclib_getBiomeCategory();
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package ru.bclib.mixin.common;
|
||||
|
||||
import com.google.common.base.Suppliers;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.biome.BiomeSource;
|
||||
import net.minecraft.world.level.biome.BiomeSource.StepFeatureData;
|
||||
|
@ -12,6 +13,7 @@ import ru.bclib.interfaces.BiomeSourceAccessor;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@Mixin(BiomeSource.class)
|
||||
public abstract class BiomeSourceMixin implements BiomeSourceAccessor {
|
||||
|
@ -19,10 +21,10 @@ public abstract class BiomeSourceMixin implements BiomeSourceAccessor {
|
|||
|
||||
@Shadow public abstract Set<Biome> possibleBiomes();
|
||||
|
||||
@Mutable @Shadow @Final private List<StepFeatureData> featuresPerStep;
|
||||
@Mutable @Shadow @Final private Supplier<List<StepFeatureData>> featuresPerStep;
|
||||
|
||||
public void bclRebuildFeatures(){
|
||||
BCLib.LOGGER.info("Rebuilding features in BiomeSource " + this);
|
||||
featuresPerStep = buildFeaturesPerStep(this.possibleBiomes().stream().toList(), true);
|
||||
featuresPerStep = Suppliers.memoize(() -> buildFeaturesPerStep(this.possibleBiomes().stream().toList(), true));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,12 +4,17 @@ import com.mojang.serialization.Lifecycle;
|
|||
import net.minecraft.core.MappedRegistry;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.core.WritableRegistry;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.biome.BiomeSource;
|
||||
import net.minecraft.world.level.biome.MultiNoiseBiomeSource;
|
||||
import net.minecraft.world.level.dimension.DimensionType;
|
||||
import net.minecraft.world.level.dimension.LevelStem;
|
||||
import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator;
|
||||
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureSet;
|
||||
import net.minecraft.world.level.levelgen.synth.NormalNoise;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
|
@ -23,39 +28,38 @@ import java.util.OptionalInt;
|
|||
@Mixin(DimensionType.class)
|
||||
public class DimensionTypeMixin {
|
||||
@Inject(
|
||||
method = "defaultDimensions(Lnet/minecraft/core/RegistryAccess;JZ)Lnet/minecraft/core/MappedRegistry;",
|
||||
method = "defaultDimensions(Lnet/minecraft/core/RegistryAccess;JZ)Lnet/minecraft/core/Registry;",
|
||||
locals = LocalCapture.CAPTURE_FAILHARD,
|
||||
at = @At("TAIL")
|
||||
)
|
||||
private static void bclib_updateDimensions(RegistryAccess registryAccess, long seed, boolean bl, CallbackInfoReturnable<MappedRegistry<LevelStem>> info, MappedRegistry<LevelStem> mappedRegistry, Registry<DimensionType> registry, Registry<Biome> biomeRegistry, Registry<NoiseGeneratorSettings> noiseSettingsRegistry, Registry<NormalNoise.NoiseParameters> noiseParamRegistry) {
|
||||
int id = mappedRegistry.getId(mappedRegistry.get(LevelStem.NETHER));
|
||||
mappedRegistry.registerOrOverride(
|
||||
OptionalInt.of(id),
|
||||
private static void bclib_updateDimensions(RegistryAccess registryAccess, long seed, boolean bl, CallbackInfoReturnable<MappedRegistry<LevelStem>> info, @NotNull MappedRegistry<LevelStem> writableRegistry, Registry<DimensionType> registry, Registry<Biome> biomeRegistry, Registry<StructureSet> structureRegistry, Registry<NoiseGeneratorSettings> noiseSettingsRegistry, Registry<NormalNoise.NoiseParameters> noiseParamRegistry) {
|
||||
int id = writableRegistry.getId(writableRegistry.get(LevelStem.NETHER));
|
||||
writableRegistry.register(
|
||||
LevelStem.NETHER,
|
||||
new LevelStem(
|
||||
() -> registry.getOrThrow(DimensionType.NETHER_LOCATION),
|
||||
registry.getOrCreateHolder(DimensionType.NETHER_LOCATION),
|
||||
new NoiseBasedChunkGenerator(
|
||||
structureRegistry,
|
||||
noiseParamRegistry,
|
||||
new BCLibNetherBiomeSource(biomeRegistry, seed),
|
||||
seed,
|
||||
() -> noiseSettingsRegistry.getOrThrow(NoiseGeneratorSettings.NETHER)
|
||||
)
|
||||
noiseSettingsRegistry.getOrCreateHolder(NoiseGeneratorSettings.NETHER))
|
||||
),
|
||||
Lifecycle.stable()
|
||||
);
|
||||
|
||||
id = mappedRegistry.getId(mappedRegistry.get(LevelStem.END));
|
||||
mappedRegistry.registerOrOverride(
|
||||
OptionalInt.of(id),
|
||||
|
||||
id = writableRegistry.getId(writableRegistry.get(LevelStem.END));
|
||||
writableRegistry.register(
|
||||
LevelStem.END,
|
||||
new LevelStem(
|
||||
() -> registry.getOrThrow(DimensionType.END_LOCATION),
|
||||
registry.getOrCreateHolder(DimensionType.END_LOCATION),
|
||||
new NoiseBasedChunkGenerator(
|
||||
structureRegistry,
|
||||
noiseParamRegistry,
|
||||
new BCLibEndBiomeSource(biomeRegistry, seed),
|
||||
seed,
|
||||
() -> noiseSettingsRegistry.getOrThrow(NoiseGeneratorSettings.END)
|
||||
)
|
||||
noiseSettingsRegistry.getOrCreateHolder(NoiseGeneratorSettings.END))
|
||||
),
|
||||
Lifecycle.stable()
|
||||
);
|
||||
|
|
|
@ -3,10 +3,9 @@ package ru.bclib.mixin.common;
|
|||
import com.mojang.authlib.GameProfileRepository;
|
||||
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||
import com.mojang.datafixers.DataFixer;
|
||||
import net.minecraft.core.RegistryAccess.RegistryHolder;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.ServerResources;
|
||||
import net.minecraft.server.WorldStem;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.progress.ChunkProgressListenerFactory;
|
||||
import net.minecraft.server.packs.repository.PackRepository;
|
||||
|
@ -32,7 +31,7 @@ import java.util.concurrent.CompletableFuture;
|
|||
@Mixin(MinecraftServer.class)
|
||||
public class MinecraftServerMixin {
|
||||
@Shadow
|
||||
private ServerResources resources;
|
||||
private MinecraftServer.ReloadableResources resources;
|
||||
|
||||
@Final
|
||||
@Shadow
|
||||
|
@ -43,7 +42,7 @@ public class MinecraftServerMixin {
|
|||
protected WorldData worldData;
|
||||
|
||||
@Inject(method = "<init>*", at = @At("TAIL"))
|
||||
private void bclib_onServerInit(Thread thread, RegistryHolder registryHolder, LevelStorageAccess levelStorageAccess, WorldData worldData, PackRepository packRepository, Proxy proxy, DataFixer dataFixer, ServerResources serverResources, MinecraftSessionService minecraftSessionService, GameProfileRepository gameProfileRepository, GameProfileCache gameProfileCache, ChunkProgressListenerFactory chunkProgressListenerFactory, CallbackInfo ci) {
|
||||
private void bclib_onServerInit(Thread thread, LevelStorageAccess levelStorageAccess, PackRepository packRepository, WorldStem worldStem, Proxy proxy, DataFixer dataFixer, MinecraftSessionService minecraftSessionService, GameProfileRepository gameProfileRepository, GameProfileCache gameProfileCache, ChunkProgressListenerFactory chunkProgressListenerFactory, CallbackInfo ci) {
|
||||
DataExchangeAPI.prepareServerside();
|
||||
}
|
||||
|
||||
|
@ -58,7 +57,7 @@ public class MinecraftServerMixin {
|
|||
}
|
||||
|
||||
private void bclib_injectRecipes() {
|
||||
RecipeManagerAccessor accessor = (RecipeManagerAccessor) resources.getRecipeManager();
|
||||
RecipeManagerAccessor accessor = (RecipeManagerAccessor) resources.managers().getRecipeManager();
|
||||
accessor.bclib_setRecipesByName(BCLRecipeManager.getMapByName(accessor.bclib_getRecipesByName()));
|
||||
accessor.bclib_setRecipes(BCLRecipeManager.getMap(accessor.bclib_getRecipes()));
|
||||
}
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
package ru.bclib.mixin.common;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.StructureFeatureManager;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.biome.Climate;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.levelgen.Aquifer;
|
||||
import net.minecraft.world.level.levelgen.Beardifier;
|
||||
import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator;
|
||||
import net.minecraft.world.level.levelgen.NoiseChunk;
|
||||
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
|
||||
import net.minecraft.world.level.levelgen.NoiseSampler;
|
||||
import net.minecraft.world.level.levelgen.*;
|
||||
import net.minecraft.world.level.levelgen.blending.Blender;
|
||||
import net.minecraft.world.level.levelgen.carver.CarvingContext;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
|
@ -30,11 +27,13 @@ import java.util.function.Supplier;
|
|||
public abstract class NoiseBasedChunkGeneratorMixin implements SurfaceProvider, NoiseGeneratorSettingsProvider {
|
||||
@Final
|
||||
@Shadow
|
||||
private NoiseSampler sampler;
|
||||
private Climate.Sampler sampler;
|
||||
|
||||
@Shadow @Final private NoiseRouter router;
|
||||
|
||||
@Final
|
||||
@Shadow
|
||||
protected Supplier<NoiseGeneratorSettings> settings;
|
||||
protected Holder<NoiseGeneratorSettings> settings;
|
||||
|
||||
@Final
|
||||
@Shadow
|
||||
|
@ -45,12 +44,12 @@ public abstract class NoiseBasedChunkGeneratorMixin implements SurfaceProvider,
|
|||
|
||||
@Override
|
||||
public NoiseGeneratorSettings bclib_getNoiseGeneratorSettings(){
|
||||
return settings.get();
|
||||
return settings.value();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public BlockState bclib_getSurface(BlockPos pos, Biome biome, ServerLevel level) {
|
||||
public BlockState bclib_getSurface(BlockPos pos, Holder<Biome> biome, ServerLevel level) {
|
||||
ChunkAccess chunkAccess = level.getChunk(pos.getX() >> 4, pos.getZ() >> 4);
|
||||
StructureFeatureManager structureFeatureManager = level.structureFeatureManager();
|
||||
NoiseBasedChunkGenerator generator = NoiseBasedChunkGenerator.class.cast(this);
|
||||
|
@ -72,7 +71,7 @@ public abstract class NoiseBasedChunkGeneratorMixin implements SurfaceProvider,
|
|||
}
|
||||
|
||||
Beardifier finalBeardifier = beardifier;
|
||||
NoiseChunk noiseChunk = chunkAccess.getOrCreateNoiseChunk(this.sampler, () -> finalBeardifier, this.settings.get(), this.globalFluidPicker, Blender.empty());
|
||||
NoiseChunk noiseChunk = chunkAccess.getOrCreateNoiseChunk(router, () -> finalBeardifier, this.settings.value(), this.globalFluidPicker, Blender.empty());
|
||||
CarvingContext carvingContext = new CarvingContext(generator, level.registryAccess(), chunkAccess.getHeightAccessorForGeneration(), noiseChunk);
|
||||
Optional<BlockState> optional = carvingContext.topMaterial(bpos -> biome, chunkAccess, pos, false);
|
||||
return optional.isPresent() ? optional.get() : bclib_air;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package ru.bclib.mixin.common.shears;
|
||||
|
||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||
import net.minecraft.advancements.critereon.ItemPredicate;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
@ -24,7 +23,8 @@ public abstract class ItemPredicateBuilderMixin {
|
|||
@Inject(method = "matches", at = @At("HEAD"), cancellable = true)
|
||||
void bclib_of(ItemStack itemStack, CallbackInfoReturnable<Boolean> cir) {
|
||||
if (this.items != null && this.items.size() == 1 && this.items.contains(Items.SHEARS)) {
|
||||
if (itemStack.is(CommonItemTags.SHEARS) || itemStack.is(FabricToolTags.SHEARS)){
|
||||
//TODO: 1.18.2 See if removing minable_shears test is having an efffect...
|
||||
if (itemStack.is(CommonItemTags.SHEARS) ){
|
||||
cir.setReturnValue(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package ru.bclib.world.generator;
|
|||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.RegistryLookupCodec;
|
||||
import net.minecraft.resources.RegistryOps;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.biome.Biome.BiomeCategory;
|
||||
|
@ -29,13 +29,8 @@ import java.util.List;
|
|||
import java.util.function.Function;
|
||||
|
||||
public class BCLibEndBiomeSource extends BCLBiomeSource {
|
||||
public static final Codec<BCLibEndBiomeSource> CODEC = RecordCodecBuilder.create((instance) -> {
|
||||
return instance.group(RegistryLookupCodec.create(Registry.BIOME_REGISTRY).forGetter((theEndBiomeSource) -> {
|
||||
return theEndBiomeSource.biomeRegistry;
|
||||
}), Codec.LONG.fieldOf("seed").stable().forGetter((theEndBiomeSource) -> {
|
||||
return theEndBiomeSource.seed;
|
||||
})).apply(instance, instance.stable(BCLibEndBiomeSource::new));
|
||||
});
|
||||
public static final Codec<BCLibEndBiomeSource> CODEC = RecordCodecBuilder.create((instance) -> instance.group(RegistryOps
|
||||
.retrieveRegistry(Registry.BIOME_REGISTRY).forGetter((theEndBiomeSource) -> theEndBiomeSource.biomeRegistry), Codec.LONG.fieldOf("seed").stable().forGetter((theEndBiomeSource) -> theEndBiomeSource.seed)).apply(instance, instance.stable(BCLibEndBiomeSource::new)));
|
||||
private static final OpenSimplexNoise SMALL_NOISE = new OpenSimplexNoise(8324);
|
||||
private Function<Point, Boolean> endLandFunction;
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package ru.bclib.world.generator;
|
|||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.RegistryLookupCodec;
|
||||
import net.minecraft.resources.RegistryOps;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.biome.Biome.BiomeCategory;
|
||||
|
@ -15,6 +15,7 @@ import ru.bclib.api.biomes.BiomeAPI;
|
|||
import ru.bclib.config.ConfigKeeper.StringArrayEntry;
|
||||
import ru.bclib.config.Configs;
|
||||
import ru.bclib.interfaces.BiomeMap;
|
||||
import ru.bclib.mixin.common.BiomeAccessor;
|
||||
import ru.bclib.world.biomes.BCLBiome;
|
||||
import ru.bclib.world.generator.map.MapStack;
|
||||
import ru.bclib.world.generator.map.hex.HexBiomeMap;
|
||||
|
@ -23,13 +24,22 @@ import ru.bclib.world.generator.map.square.SquareBiomeMap;
|
|||
import java.util.List;
|
||||
|
||||
public class BCLibNetherBiomeSource extends BCLBiomeSource {
|
||||
public static final Codec<BCLibNetherBiomeSource> CODEC = RecordCodecBuilder.create((instance) -> {
|
||||
return instance.group(RegistryLookupCodec.create(Registry.BIOME_REGISTRY).forGetter((theEndBiomeSource) -> {
|
||||
return theEndBiomeSource.biomeRegistry;
|
||||
}), Codec.LONG.fieldOf("seed").stable().forGetter((theEndBiomeSource) -> {
|
||||
return theEndBiomeSource.seed;
|
||||
})).apply(instance, instance.stable(BCLibNetherBiomeSource::new));
|
||||
});
|
||||
|
||||
public static final Codec<BCLibNetherBiomeSource> CODEC = RecordCodecBuilder
|
||||
.create(instance -> instance
|
||||
.group(RegistryOps
|
||||
.retrieveRegistry(Registry.BIOME_REGISTRY)
|
||||
.forGetter(source -> source.biomeRegistry)
|
||||
,
|
||||
Codec
|
||||
.LONG
|
||||
.fieldOf("seed")
|
||||
.stable()
|
||||
.forGetter(source -> source.seed)
|
||||
)
|
||||
.apply(instance, instance.stable(BCLibNetherBiomeSource::new))
|
||||
);
|
||||
|
||||
private BiomeMap biomeMap;
|
||||
|
||||
private static boolean forceLegacyGenerator = false;
|
||||
|
@ -95,7 +105,7 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource {
|
|||
return true;
|
||||
}
|
||||
|
||||
if (GeneratorOptions.addNetherBiomesByCategory() && biome.getBiomeCategory() == BiomeCategory.NETHER) {
|
||||
if (GeneratorOptions.addNetherBiomesByCategory() && (biome instanceof BiomeAccessor) && ((BiomeAccessor)(Object)biome).bclib_getBiomeCategory()== BiomeCategory.NETHER) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
accessWidener v1 named
|
||||
|
||||
# Classes
|
||||
accessible class net/minecraft/server/MinecraftServer$ReloadableResources
|
||||
accessible class net/minecraft/client/Minecraft$ExperimentalDialogType
|
||||
accessible class net/minecraft/world/level/levelgen/SurfaceRules$Context
|
||||
accessible class net/minecraft/world/level/levelgen/SurfaceRules$Condition
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
"package": "ru.bclib.mixin.client",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"client": [
|
||||
"SimpleReloadableResourceManagerMixin",
|
||||
"EnchantingTableBlockMixin",
|
||||
"ClientRecipeBookMixin",
|
||||
"ModelManagerMixin",
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
"package": "ru.bclib.mixin.common",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"mixins": [
|
||||
"SimpleReloadableResourceManagerMixin",
|
||||
"BiomeGenerationSettingsAccessor",
|
||||
"shears.DiggingEnchantmentMixin",
|
||||
"shears.ItemPredicateBuilderMixin",
|
||||
|
@ -42,7 +41,8 @@
|
|||
"AnvilBlockMixin",
|
||||
"AnvilMenuMixin",
|
||||
"TagLoaderMixin",
|
||||
"MainMixin"
|
||||
"MainMixin",
|
||||
"BiomeAccessor"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue