use of net.minecraft.util.math.BlockPointer in project Biome-Makeover by Lemonszz.
the class BMWorldEvents method init.
public static void init() {
DispenserBlock.registerBehavior(Items.CROSSBOW, new FallibleItemDispenserBehavior() {
public ItemStack dispenseSilently(BlockPointer pointer, ItemStack stack) {
BlockPos blockPos = pointer.getBlockPos().offset(pointer.getBlockState().get(DispenserBlock.FACING));
List<StoneGolemEntity> list = pointer.getWorld().getEntitiesByClass(StoneGolemEntity.class, new Box(blockPos), (golem) -> !golem.isHolding(Items.CROSSBOW) && golem.isPlayerCreated() && golem.isAlive());
if (!list.isEmpty()) {
list.get(0).equipStack(EquipmentSlot.MAINHAND, stack.copy());
stack.decrement(1);
this.setSuccess(true);
return stack;
} else {
return super.dispenseSilently(pointer, stack);
}
}
});
// Adjudicator Drop Illunite Shard
ServerEntityCombatEvents.AFTER_KILLED_OTHER_ENTITY.register((world, entity, killedEntity) -> {
if (!world.isClient() && entity instanceof PlayerEntity && killedEntity instanceof EvokerEntity) {
if (!LootBlocker.isBlocked(killedEntity)) {
if (world.random.nextFloat() < 0.15F) {
killedEntity.dropStack(new ItemStack(BMItems.ILLUNITE_SHARD, 1 + world.random.nextInt(2)));
}
}
}
});
}
Aggregations