[Feature] Identify POI by BlockTags

This commit is contained in:
Frank 2022-07-21 12:11:39 +02:00
parent c622afc549
commit 5ac1eed54e
6 changed files with 98 additions and 13 deletions

View file

@ -0,0 +1,29 @@
package org.betterx.bclib.mixin.common;
import org.betterx.bclib.api.v2.poi.PoiTypeExtension;
import net.minecraft.tags.TagKey;
import net.minecraft.world.entity.ai.village.poi.PoiType;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(PoiType.class)
public class PoiTypeMixin implements PoiTypeExtension {
private TagKey<Block> bcl_tag = null;
@Inject(method = "is", cancellable = true, at = @At("HEAD"))
void bcl_is(BlockState blockState, CallbackInfoReturnable<Boolean> cir) {
if (bcl_tag != null && blockState.is(bcl_tag)) {
cir.setReturnValue(true);
}
}
public void bcl_setTag(TagKey<Block> tag) {
bcl_tag = tag;
}
}