Search in sources :

Example 1 with PortalSize

use of net.minecraft.block.PortalSize in project minecolonies by ldtteam.

the class EntityAIWorkNether method openPortal.

/**
 * Open the portal to the nether if it's not open
 */
protected IAIState openPortal() {
    // Attempt to light the portal and travel
    final BlockPos portal = getOwnBuilding().getPortalLocation();
    final BlockState block = world.getBlockState(portal);
    if (portal != null && currentRecipeStorage != null) {
        final Optional<PortalSize> ps = PortalSize.findPortalShape(world, portal, p -> p.isValid(), Direction.Axis.X);
        if (!ps.isPresent()) {
            // Can't find the portal
            return IDLE;
        }
        if (!block.is(Blocks.NETHER_PORTAL)) {
            useFlintAndSteel();
            ps.get().createPortalBlocks();
            return NETHER_LEAVE;
        }
    }
    return START_WORKING;
}
Also used : BlockState(net.minecraft.block.BlockState) BlockPos(net.minecraft.util.math.BlockPos) PortalSize(net.minecraft.block.PortalSize)

Example 2 with PortalSize

use of net.minecraft.block.PortalSize in project minecolonies by Minecolonies.

the class EntityAIWorkNether method openPortal.

/**
 * Open the portal to the nether if it's not open
 */
protected IAIState openPortal() {
    // Attempt to light the portal and travel
    final BlockPos portal = building.getPortalLocation();
    if (portal != null && currentRecipeStorage != null) {
        if (walkToBlock(portal, 1)) {
            return getState();
        }
        final BlockState block = world.getBlockState(portal);
        final Optional<PortalSize> ps = PortalSize.findPortalShape(world, portal, p -> p.isValid(), Direction.Axis.X);
        if (!ps.isPresent()) {
            // Can't find the portal
            return IDLE;
        }
        if (!block.is(Blocks.NETHER_PORTAL)) {
            useFlintAndSteel();
            ps.get().createPortalBlocks();
            return NETHER_LEAVE;
        }
    }
    return START_WORKING;
}
Also used : BlockState(net.minecraft.block.BlockState) BlockPos(net.minecraft.util.math.BlockPos) PortalSize(net.minecraft.block.PortalSize)

Aggregations

BlockState (net.minecraft.block.BlockState)2 PortalSize (net.minecraft.block.PortalSize)2 BlockPos (net.minecraft.util.math.BlockPos)2