Search in sources :

Example 1 with BolloomKnotEntity

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;
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) FenceBlock(net.minecraft.block.FenceBlock) BoatEntity(net.minecraft.entity.item.BoatEntity) Entity(net.minecraft.entity.Entity) BolloomBalloonEntity(com.minecraftabnormals.endergetic.common.entities.bolloom.BolloomBalloonEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) BolloomKnotEntity(com.minecraftabnormals.endergetic.common.entities.bolloom.BolloomKnotEntity) Block(net.minecraft.block.Block) FenceBlock(net.minecraft.block.FenceBlock) DispenserBlock(net.minecraft.block.DispenserBlock) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) ItemStack(net.minecraft.item.ItemStack) BolloomKnotEntity(com.minecraftabnormals.endergetic.common.entities.bolloom.BolloomKnotEntity)

Aggregations

BolloomBalloonEntity (com.minecraftabnormals.endergetic.common.entities.bolloom.BolloomBalloonEntity)1 BolloomKnotEntity (com.minecraftabnormals.endergetic.common.entities.bolloom.BolloomKnotEntity)1 Block (net.minecraft.block.Block)1 DispenserBlock (net.minecraft.block.DispenserBlock)1 FenceBlock (net.minecraft.block.FenceBlock)1 Entity (net.minecraft.entity.Entity)1 LivingEntity (net.minecraft.entity.LivingEntity)1 BoatEntity (net.minecraft.entity.item.BoatEntity)1 PlayerEntity (net.minecraft.entity.player.PlayerEntity)1 ItemStack (net.minecraft.item.ItemStack)1 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)1 BlockPos (net.minecraft.util.math.BlockPos)1 World (net.minecraft.world.World)1