use of com.minecraftabnormals.endergetic.common.entities.bolloom.BolloomKnotEntity in project endergetic by team-abnormals.
the class BolloomBalloonItem method useOn.
@Override
public ActionResultType useOn(ItemUseContext context) {
BlockPos pos = context.getClickedPos();
World world = context.getLevel();
Block block = world.getBlockState(pos).getBlock();
if (block instanceof FenceBlock) {
if (this.isAirUpwards(world, pos)) {
if (!world.isClientSide) {
ItemStack stack = context.getItemInHand();
if (this.attachToFence(pos, world, stack)) {
stack.shrink(1);
return ActionResultType.SUCCESS;
}
}
} else {
return ActionResultType.FAIL;
}
for (Entity entity : world.getEntitiesOfClass(Entity.class, new AxisAlignedBB(pos))) {
if (entity instanceof BolloomKnotEntity) {
if (((BolloomKnotEntity) entity).hasMaxBalloons()) {
return ActionResultType.FAIL;
}
}
}
}
return ActionResultType.PASS;
}
Aggregations