Merge remote-tracking branch 'upstream/main' into feature/TagAPITypeSafety
This commit is contained in:
commit
75338586ab
5 changed files with 55 additions and 9 deletions
|
@ -177,12 +177,10 @@ public class BiomeAPI {
|
||||||
public static void registerWorldData(WorldData w){
|
public static void registerWorldData(WorldData w){
|
||||||
worldData = w;
|
worldData = w;
|
||||||
if (worldData!=null){
|
if (worldData!=null){
|
||||||
|
|
||||||
worldData.worldGenSettings().dimensions().forEach(dim->{
|
worldData.worldGenSettings().dimensions().forEach(dim->{
|
||||||
StructureSettingsAccessor a = (StructureSettingsAccessor)dim.generator().getSettings();
|
StructureSettingsAccessor a = (StructureSettingsAccessor)dim.generator().getSettings();
|
||||||
STRUCTURE_STARTS.entrySet().forEach(entry -> applyStructureStarts(a, entry.getValue()));
|
STRUCTURE_STARTS.entrySet().forEach(entry -> applyStructureStarts(a, entry.getValue()));
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -542,6 +540,7 @@ public class BiomeAPI {
|
||||||
List<BiConsumer<ResourceLocation, Biome>> modifications = MODIFICATIONS.get(level.dimension());
|
List<BiConsumer<ResourceLocation, Biome>> modifications = MODIFICATIONS.get(level.dimension());
|
||||||
if (modifications == null) {
|
if (modifications == null) {
|
||||||
biomes.forEach(biome -> sortBiomeFeatures(biome));
|
biomes.forEach(biome -> sortBiomeFeatures(biome));
|
||||||
|
((BiomeSourceAccessor) source).bclRebuildFeatures();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -898,8 +897,15 @@ public class BiomeAPI {
|
||||||
public static void registerStructureEvents(){
|
public static void registerStructureEvents(){
|
||||||
DynamicRegistrySetupCallback.EVENT.register(registryManager -> {
|
DynamicRegistrySetupCallback.EVENT.register(registryManager -> {
|
||||||
Optional<? extends Registry<NoiseGeneratorSettings>> oGeneratorRegistry = registryManager.registry(Registry.NOISE_GENERATOR_SETTINGS_REGISTRY);
|
Optional<? extends Registry<NoiseGeneratorSettings>> oGeneratorRegistry = registryManager.registry(Registry.NOISE_GENERATOR_SETTINGS_REGISTRY);
|
||||||
Optional<? extends Registry<Codec<? extends BiomeSource>>> oBiomeSourceRegistry = registryManager.registry(Registry.BIOME_SOURCE_REGISTRY);
|
// Optional<? extends Registry<Codec<? extends BiomeSource>>> oBiomeSourceRegistry = registryManager.registry(Registry.BIOME_SOURCE_REGISTRY);
|
||||||
|
//
|
||||||
|
// if (oBiomeSourceRegistry.isPresent()) {
|
||||||
|
// RegistryEntryAddedCallback
|
||||||
|
// .event(oBiomeSourceRegistry.get())
|
||||||
|
// .register((rawId, id, source) -> {
|
||||||
|
// BCLib.LOGGER.info(" #### " + rawId + ", " + source + ", " + id);
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
if (oGeneratorRegistry.isPresent()) {
|
if (oGeneratorRegistry.isPresent()) {
|
||||||
oGeneratorRegistry.get().forEach(BiomeAPI::registerNoiseGeneratorAndChangeSurfaceRules);
|
oGeneratorRegistry.get().forEach(BiomeAPI::registerNoiseGeneratorAndChangeSurfaceRules);
|
||||||
|
|
|
@ -23,6 +23,7 @@ import ru.bclib.client.render.BCLRenderLayer;
|
||||||
import ru.bclib.interfaces.BlockModelProvider;
|
import ru.bclib.interfaces.BlockModelProvider;
|
||||||
import ru.bclib.interfaces.RenderLayerProvider;
|
import ru.bclib.interfaces.RenderLayerProvider;
|
||||||
import ru.bclib.interfaces.TagProvider;
|
import ru.bclib.interfaces.TagProvider;
|
||||||
|
import ru.bclib.items.tool.BaseShearsItem;
|
||||||
import ru.bclib.util.MHelper;
|
import ru.bclib.util.MHelper;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -36,7 +37,7 @@ public class BaseLeavesBlock extends LeavesBlock implements BlockModelProvider,
|
||||||
return FabricBlockSettings
|
return FabricBlockSettings
|
||||||
.copyOf(Blocks.OAK_LEAVES)
|
.copyOf(Blocks.OAK_LEAVES)
|
||||||
.mapColor(color)
|
.mapColor(color)
|
||||||
.requiresTool()
|
//.requiresTool()
|
||||||
.allowsSpawning((state, world, pos, type) -> false)
|
.allowsSpawning((state, world, pos, type) -> false)
|
||||||
.suffocates((state, world, pos) -> false)
|
.suffocates((state, world, pos) -> false)
|
||||||
.blockVision((state, world, pos) -> false);
|
.blockVision((state, world, pos) -> false);
|
||||||
|
@ -72,7 +73,7 @@ public class BaseLeavesBlock extends LeavesBlock implements BlockModelProvider,
|
||||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
ItemStack tool = builder.getParameter(LootContextParams.TOOL);
|
ItemStack tool = builder.getParameter(LootContextParams.TOOL);
|
||||||
if (tool != null) {
|
if (tool != null) {
|
||||||
if (tool.isCorrectToolForDrops(state) || EnchantmentHelper.getItemEnchantmentLevel(
|
if (BaseShearsItem.isShear(tool) || EnchantmentHelper.getItemEnchantmentLevel(
|
||||||
Enchantments.SILK_TOUCH,
|
Enchantments.SILK_TOUCH,
|
||||||
tool
|
tool
|
||||||
) > 0) {
|
) > 0) {
|
||||||
|
@ -95,7 +96,7 @@ public class BaseLeavesBlock extends LeavesBlock implements BlockModelProvider,
|
||||||
@Override
|
@Override
|
||||||
public void addTags(List<Named<Block>> blockTags, List<Named<Item>> itemTags) {
|
public void addTags(List<Named<Block>> blockTags, List<Named<Item>> itemTags) {
|
||||||
blockTags.add(FabricMineableTags.SHEARS_MINEABLE);
|
blockTags.add(FabricMineableTags.SHEARS_MINEABLE);
|
||||||
blockTags.add(TagAPI.MINEABLE_HOE);
|
//blockTags.add(TagAPI.MINEABLE_HOE);
|
||||||
blockTags.add(BlockTags.LEAVES);
|
blockTags.add(BlockTags.LEAVES);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,10 @@ public class BaseShearsItem extends ShearsItem {
|
||||||
super(properties);
|
super(properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isShear(ItemStack tool){
|
||||||
|
return tool.is(Items.SHEARS) | tool.is(TagAPI.ITEM_COMMON_SHEARS) || tool.is(TagAPI.ITEM_SHEARS);
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isShear(ItemStack itemStack, Item item){
|
public static boolean isShear(ItemStack itemStack, Item item){
|
||||||
if (item == Items.SHEARS){
|
if (item == Items.SHEARS){
|
||||||
return itemStack.is(item) | itemStack.is(TagAPI.ITEM_COMMON_SHEARS) || itemStack.is(TagAPI.ITEM_SHEARS);
|
return itemStack.is(item) | itemStack.is(TagAPI.ITEM_COMMON_SHEARS) || itemStack.is(TagAPI.ITEM_SHEARS);
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
package ru.bclib.mixin.common.shears;
|
||||||
|
|
||||||
|
import net.minecraft.advancements.critereon.ItemPredicate;
|
||||||
|
import net.minecraft.advancements.critereon.ItemPredicate.Builder;
|
||||||
|
import net.minecraft.tags.Tag;
|
||||||
|
import net.minecraft.world.item.Item;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.item.Items;
|
||||||
|
import net.minecraft.world.level.ItemLike;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.spongepowered.asm.mixin.Final;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
import ru.bclib.api.TagAPI;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
@Mixin(ItemPredicate.class)
|
||||||
|
public abstract class ItemPredicateBuilderMixin {
|
||||||
|
|
||||||
|
@Shadow @Final private @Nullable Set<Item> items;
|
||||||
|
|
||||||
|
@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(TagAPI.ITEM_COMMON_SHEARS) || itemStack.is(TagAPI.ITEM_SHEARS)){
|
||||||
|
cir.setReturnValue(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,6 +7,7 @@
|
||||||
"SimpleReloadableResourceManagerMixin",
|
"SimpleReloadableResourceManagerMixin",
|
||||||
"BiomeGenerationSettingsAccessor",
|
"BiomeGenerationSettingsAccessor",
|
||||||
"shears.DiggingEnchantmentMixin",
|
"shears.DiggingEnchantmentMixin",
|
||||||
|
"shears.ItemPredicateBuilderMixin",
|
||||||
"LayerLightSectionStorageMixin",
|
"LayerLightSectionStorageMixin",
|
||||||
"NoiseBasedChunkGeneratorMixin",
|
"NoiseBasedChunkGeneratorMixin",
|
||||||
"NoiseGeneratorSettingsMixin",
|
"NoiseGeneratorSettingsMixin",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue