Java Code Examples for net.minecraft.util.EnumFacing#EAST

The following examples show how to use net.minecraft.util.EnumFacing#EAST . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Scrubber.java    From EmergingTechnology with MIT License 6 votes vote down vote up
@Override
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) {
    if (!worldIn.isRemote) {
        IBlockState north = worldIn.getBlockState(pos.north());
        IBlockState east = worldIn.getBlockState(pos.east());
        IBlockState south = worldIn.getBlockState(pos.south());
        IBlockState west = worldIn.getBlockState(pos.west());

        EnumFacing face = (EnumFacing) state.getValue(FACING);

        if (face == EnumFacing.NORTH && north.isFullBlock() && !south.isFullBlock()) {
            face = EnumFacing.SOUTH;
        } else if (face == EnumFacing.SOUTH && south.isFullBlock() && !north.isFullBlock()) {
            face = EnumFacing.NORTH;
        } else if (face == EnumFacing.EAST && east.isFullBlock() && !west.isFullBlock()) {
            face = EnumFacing.WEST;
        } else if (face == EnumFacing.WEST && west.isFullBlock() && !east.isFullBlock()) {
            face = EnumFacing.EAST;
        }

        worldIn.setBlockState(pos, state.withProperty(FACING, face));
    }
}
 
Example 2
Source File: Cooker.java    From EmergingTechnology with MIT License 6 votes vote down vote up
@Override
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) {
    if (!worldIn.isRemote) {
        IBlockState north = worldIn.getBlockState(pos.north());
        IBlockState east = worldIn.getBlockState(pos.east());
        IBlockState south = worldIn.getBlockState(pos.south());
        IBlockState west = worldIn.getBlockState(pos.west());

        EnumFacing face = (EnumFacing) state.getValue(FACING);

        if (face == EnumFacing.NORTH && north.isFullBlock() && !south.isFullBlock()) {
            face = EnumFacing.SOUTH;
        } else if (face == EnumFacing.SOUTH && south.isFullBlock() && !north.isFullBlock()) {
            face = EnumFacing.NORTH;
        } else if (face == EnumFacing.EAST && east.isFullBlock() && !west.isFullBlock()) {
            face = EnumFacing.WEST;
        } else if (face == EnumFacing.WEST && west.isFullBlock() && !east.isFullBlock()) {
            face = EnumFacing.EAST;
        }

        worldIn.setBlockState(pos, state.withProperty(FACING, face));
    }
}
 
Example 3
Source File: Piezoelectric.java    From EmergingTechnology with MIT License 6 votes vote down vote up
@Override
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) {
    if (!worldIn.isRemote) {
        IBlockState north = worldIn.getBlockState(pos.north());
        IBlockState east = worldIn.getBlockState(pos.east());
        IBlockState south = worldIn.getBlockState(pos.south());
        IBlockState west = worldIn.getBlockState(pos.west());

        EnumFacing face = (EnumFacing) state.getValue(FACING);

        if (face == EnumFacing.NORTH && north.isFullBlock() && !south.isFullBlock()) {
            face = EnumFacing.SOUTH;
        } else if (face == EnumFacing.SOUTH && south.isFullBlock() && !north.isFullBlock()) {
            face = EnumFacing.NORTH;
        } else if (face == EnumFacing.EAST && east.isFullBlock() && !west.isFullBlock()) {
            face = EnumFacing.WEST;
        } else if (face == EnumFacing.WEST && west.isFullBlock() && !east.isFullBlock()) {
            face = EnumFacing.EAST;
        }

        worldIn.setBlockState(pos, state.withProperty(FACING, face));
    }
}
 
Example 4
Source File: TidalGenerator.java    From EmergingTechnology with MIT License 6 votes vote down vote up
@Override
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) {
    if (!worldIn.isRemote) {
        IBlockState north = worldIn.getBlockState(pos.north());
        IBlockState east = worldIn.getBlockState(pos.east());
        IBlockState south = worldIn.getBlockState(pos.south());
        IBlockState west = worldIn.getBlockState(pos.west());

        EnumFacing face = (EnumFacing) state.getValue(FACING);

        if (face == EnumFacing.NORTH && north.isFullBlock() && !south.isFullBlock()) {
            face = EnumFacing.SOUTH;
        } else if (face == EnumFacing.SOUTH && south.isFullBlock() && !north.isFullBlock()) {
            face = EnumFacing.NORTH;
        } else if (face == EnumFacing.EAST && east.isFullBlock() && !west.isFullBlock()) {
            face = EnumFacing.WEST;
        } else if (face == EnumFacing.WEST && west.isFullBlock() && !east.isFullBlock()) {
            face = EnumFacing.EAST;
        }

        worldIn.setBlockState(pos, state.withProperty(FACING, face));
    }
}
 
Example 5
Source File: BlockPackager.java    From CommunityMod with GNU Lesser General Public License v2.1 6 votes vote down vote up
public EnumFacing getFacingFromMeta(int meta) {
	if (meta == 0) {
		return EnumFacing.EAST;
	}
	if (meta == 1) {
		return EnumFacing.WEST;
	}
	if (meta == 2) {
		return EnumFacing.NORTH;
	}
	if (meta == 3) {
		return EnumFacing.SOUTH;
	}
	if (meta == 4) {
		return EnumFacing.UP;
	}
	if (meta == 5) {
		return EnumFacing.DOWN;
	}
	return EnumFacing.EAST;
}
 
Example 6
Source File: BiomassGenerator.java    From EmergingTechnology with MIT License 6 votes vote down vote up
@Override
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) {
    if (!worldIn.isRemote) {
        IBlockState north = worldIn.getBlockState(pos.north());
        IBlockState east = worldIn.getBlockState(pos.east());
        IBlockState south = worldIn.getBlockState(pos.south());
        IBlockState west = worldIn.getBlockState(pos.west());

        EnumFacing face = (EnumFacing) state.getValue(FACING);

        if (face == EnumFacing.NORTH && north.isFullBlock() && !south.isFullBlock()) {
            face = EnumFacing.SOUTH;
        } else if (face == EnumFacing.SOUTH && south.isFullBlock() && !north.isFullBlock()) {
            face = EnumFacing.NORTH;
        } else if (face == EnumFacing.EAST && east.isFullBlock() && !west.isFullBlock()) {
            face = EnumFacing.WEST;
        } else if (face == EnumFacing.WEST && west.isFullBlock() && !east.isFullBlock()) {
            face = EnumFacing.EAST;
        }

        worldIn.setBlockState(pos, state.withProperty(FACING, face));
    }
}
 
Example 7
Source File: SignalsUtils.java    From Signals with GNU General Public License v3.0 6 votes vote down vote up
public static EnumFacing getRelativeHorizonal(BlockPos original, BlockPos neighbor){
    int relX = neighbor.getX() - original.getX();
    int relZ = neighbor.getZ() - original.getZ();

    if(relZ == 0) {
        if(relX == 1) return EnumFacing.EAST;
        if(relX == -1) return EnumFacing.WEST;
    }

    if(relX == 0) {
        if(relZ > 0) return EnumFacing.SOUTH;
        if(relZ < 0) return EnumFacing.NORTH;
    }

    return null;
}
 
Example 8
Source File: BlockUnpackager.java    From CommunityMod with GNU Lesser General Public License v2.1 6 votes vote down vote up
public EnumFacing getFacingFromMeta(int meta) {
	if (meta == 0 || meta == 6) {
		return EnumFacing.EAST;
	}
	if (meta == 1 || meta == 7) {
		return EnumFacing.WEST;
	}
	if (meta == 2 || meta == 8) {
		return EnumFacing.NORTH;
	}
	if (meta == 3 || meta == 9) {
		return EnumFacing.SOUTH;
	}
	if (meta == 4 || meta == 10) {
		return EnumFacing.UP;
	}
	if (meta == 5 || meta == 11) {
		return EnumFacing.DOWN;
	}
	return EnumFacing.EAST;
}
 
Example 9
Source File: IslandData.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
public void enablePortal(EnumFacing facing)
{
	if(facing == EnumFacing.NORTH)
		northPortalState = PortalEnumType.Enabled;
	else if(facing == EnumFacing.SOUTH)
		southPortalState = PortalEnumType.Enabled;
	else if(facing == EnumFacing.EAST)
		eastPortalState = PortalEnumType.Enabled;
	else if(facing == EnumFacing.WEST)
		westPortalState = PortalEnumType.Enabled;
}
 
Example 10
Source File: AbstractRailRenderer.java    From Signals with GNU General Public License v3.0 5 votes vote down vote up
public static int getRailHeightOffset(NetworkRail<MCPos> rail, EnumFacing dir){
    switch(((MCNetworkRail)rail).getCurDir()){
        case ASCENDING_EAST:
            return dir == EnumFacing.EAST ? 1 : (dir == EnumFacing.WEST ? -1 : 0);
        case ASCENDING_NORTH:
            return dir == EnumFacing.NORTH ? 1 : (dir == EnumFacing.SOUTH ? -1 : 0);
        case ASCENDING_SOUTH:
            return dir == EnumFacing.SOUTH ? 1 : (dir == EnumFacing.NORTH ? -1 : 0);
        case ASCENDING_WEST:
            return dir == EnumFacing.WEST ? 1 : (dir == EnumFacing.EAST ? -1 : 0);
        default:
            return 0;
    }
}
 
Example 11
Source File: FacingHelper.java    From EmergingTechnology with MIT License 5 votes vote down vote up
public static EnumFacing intToFacing(int id) {
    switch(id) {
        case 1:
            return EnumFacing.NORTH;
        case 2:
            return EnumFacing.EAST;
        case 3:
            return EnumFacing.SOUTH;
        case 4:
            return EnumFacing.WEST;
        default:
            return EnumFacing.NORTH;
    }
}
 
Example 12
Source File: TeleportEntityNetherPortal.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected EnumFacing getPortalOrientation(World world, BlockPos portalPos)
{
    if (world.getBlockState(portalPos.west()).getBlock() == Blocks.PORTAL ||
        world.getBlockState(portalPos.east()).getBlock() == Blocks.PORTAL)
    {
        return EnumFacing.EAST;
    }
    else if (world.getBlockState(portalPos.north()).getBlock() == Blocks.PORTAL ||
             world.getBlockState(portalPos.south()).getBlock() == Blocks.PORTAL)
    {
        return EnumFacing.SOUTH;
    }

    return EnumFacing.NORTH;
}
 
Example 13
Source File: BlockBarrel.java    From Sakura_mod with MIT License 5 votes vote down vote up
public void setDefaultFacing(World worldIn, BlockPos pos, IBlockState state)
{
    if (!worldIn.isRemote)
    {
         IBlockState iblockstate = worldIn.getBlockState(pos.north());
         IBlockState iblockstate1 = worldIn.getBlockState(pos.south());
         IBlockState iblockstate2 = worldIn.getBlockState(pos.west());
         IBlockState iblockstate3 = worldIn.getBlockState(pos.east());
         EnumFacing enumfacing = state.getValue(FACING);

         if (enumfacing == EnumFacing.NORTH && iblockstate.isFullBlock() && !iblockstate1.isFullBlock())
         {
             enumfacing = EnumFacing.SOUTH;
         }
         else if (enumfacing == EnumFacing.SOUTH && iblockstate1.isFullBlock() && !iblockstate.isFullBlock())
         {
             enumfacing = EnumFacing.NORTH;
         }
         else if (enumfacing == EnumFacing.WEST && iblockstate2.isFullBlock() && !iblockstate3.isFullBlock())
         {
             enumfacing = EnumFacing.EAST;
         }
         else if (enumfacing == EnumFacing.EAST && iblockstate3.isFullBlock() && !iblockstate2.isFullBlock())
         {
             enumfacing = EnumFacing.WEST;
         }

         worldIn.setBlockState(pos, state.withProperty(FACING, enumfacing), 2);
     }
 }
 
Example 14
Source File: BlockBarrelDistillation.java    From Sakura_mod with MIT License 5 votes vote down vote up
public void setDefaultFacing(World worldIn, BlockPos pos, IBlockState state)
{
    if (!worldIn.isRemote)
    {
         IBlockState iblockstate = worldIn.getBlockState(pos.north());
         IBlockState iblockstate1 = worldIn.getBlockState(pos.south());
         IBlockState iblockstate2 = worldIn.getBlockState(pos.west());
         IBlockState iblockstate3 = worldIn.getBlockState(pos.east());
         EnumFacing enumfacing = state.getValue(FACING);

         if (enumfacing == EnumFacing.NORTH && iblockstate.isFullBlock() && !iblockstate1.isFullBlock())
         {
             enumfacing = EnumFacing.SOUTH;
         }
         else if (enumfacing == EnumFacing.SOUTH && iblockstate1.isFullBlock() && !iblockstate.isFullBlock())
         {
             enumfacing = EnumFacing.NORTH;
         }
         else if (enumfacing == EnumFacing.WEST && iblockstate2.isFullBlock() && !iblockstate3.isFullBlock())
         {
             enumfacing = EnumFacing.EAST;
         }
         else if (enumfacing == EnumFacing.EAST && iblockstate3.isFullBlock() && !iblockstate2.isFullBlock())
         {
             enumfacing = EnumFacing.WEST;
         }

         worldIn.setBlockState(pos, state.withProperty(FACING, enumfacing), 2);
     }
 }
 
Example 15
Source File: DirectionConverter.java    From NOVA-Core with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public EnumFacing toNative(Direction novaObj) {
	switch (novaObj) {
		case DOWN:  return EnumFacing.DOWN;
		case UP:    return EnumFacing.UP;
		case NORTH: return EnumFacing.NORTH;
		case SOUTH: return EnumFacing.SOUTH;
		case WEST:  return EnumFacing.WEST;
		case EAST:  return EnumFacing.EAST;
		default: return (EnumFacing) null;
	}
}
 
Example 16
Source File: WorldGenFallenTree.java    From CommunityMod with GNU Lesser General Public License v2.1 4 votes vote down vote up
public boolean generate(World worldIn, Random rand, BlockPos position) {
    int num = rand.nextInt(5);
    EnumFacing orientation;
    if (num == 0) {
        orientation = EnumFacing.EAST;
        stateWood = stateWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X);
    } else if (num == 1) {
        orientation = EnumFacing.WEST;
        stateWood = stateWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X);
    } else if (num == 1) {
        orientation = EnumFacing.SOUTH;
        stateWood = stateWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z);
    } else {
        orientation = EnumFacing.NORTH;
        stateWood = stateWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z);
    }
    int i = rand.nextInt(2) + this.minTreeLength;
    boolean flag = true;

    if (position.getY() >= 1 && position.getY() + i + 1 <= worldIn.getHeight()) {
        for (int j = position.getY(); j <= position.getY() + 1 + i; ++j) {
            int k = 1;

            if (j == position.getY()) {
                k = 0;
            }

            if (j >= position.getY() + 1 + i - 2) {
                k = 2;
            }

            BlockPos.MutableBlockPos mutablePos = new BlockPos.MutableBlockPos();

            for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l) {
                for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1) {
                    if (j >= 0 && j < worldIn.getHeight()) {
                        if (!this.isReplaceable(worldIn, mutablePos.setPos(l, j, i1))) {
                            flag = false;
                        }
                    } else {
                        flag = false;
                    }
                }
            }
        }

        if (!flag) {
            return false;
        } else {
            IBlockState state = worldIn.getBlockState(position.down());

            if (state.getBlock().canSustainPlant(state, worldIn, position.down(), net.minecraft.util.EnumFacing.UP, (net.minecraft.block.BlockSapling) Blocks.SAPLING) && position.getY() < worldIn.getHeight() - i - 1) {
                state.getBlock().onPlantGrow(state, worldIn, position.down(), position);

                for (int j3 = 0; j3 < i; ++j3) {
                    BlockPos offsetPos = position.offset(orientation, j3);
                    state = worldIn.getBlockState(offsetPos);

                    if (state.getBlock().isAir(state, worldIn, offsetPos) || state.getBlock().isLeaves(state, worldIn, offsetPos) || state.getMaterial() == Material.VINE) {
                        this.setBlockAndNotifyAdequately(worldIn, position.offset(orientation, j3), this.stateWood);
                    }
                }
                return true;
            } else {
                return false;
            }
        }
    } else {
        return false;
    }
}
 
Example 17
Source File: ObsidianReplaceModule.java    From seppuku with GNU General Public License v3.0 4 votes vote down vote up
private EnumFacing calculateFaceForPlacement(final BlockPos structurePosition,
                                             final BlockPos blockPosition) {
    final BiFunction<Integer, String, Integer> throwingClamp = (number, axis) -> {
        if (number < -1 || number > 1)
            throw new IllegalArgumentException(
                    String.format("Difference in %s is illegal, " +
                            "positions are too far apart.", axis));

        return number;
    };

    final int diffX = throwingClamp.apply(
            structurePosition.getX() - blockPosition.getX(), "x-axis");
    switch (diffX) {
        case 1:
            return EnumFacing.WEST;
        case -1:
            return EnumFacing.EAST;
        default:
            break;
    }

    final int diffY = throwingClamp.apply(
            structurePosition.getY() - blockPosition.getY(), "y-axis");
    switch (diffY) {
        case 1:
            return EnumFacing.DOWN;
        case -1:
            return EnumFacing.UP;
        default:
            break;
    }

    final int diffZ = throwingClamp.apply(
            structurePosition.getZ() - blockPosition.getZ(), "z-axis");
    switch (diffZ) {
        case 1:
            return EnumFacing.NORTH;
        case -1:
            return EnumFacing.SOUTH;
        default:
            break;
    }

    return null;
}
 
Example 18
Source File: SmallVesselHighlightHandler.java    From TFC2 with GNU General Public License v3.0 4 votes vote down vote up
public static void drawFace(AxisAlignedBB aabb, float[] color, EnumFacing facing)
{
	//TODO: Add UV coords for other faces
	Tessellator tessellator = Tessellator.getInstance();
	VertexBuffer buffer = tessellator.getBuffer();
	if(facing == EnumFacing.UP)
	{
		buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
		buffer.pos(aabb.minX, aabb.maxY, aabb.maxZ).tex(0, 1).color(color[0], color[1], color[2], color[3]).endVertex();
		buffer.pos(aabb.minX, aabb.maxY, aabb.minZ).tex(0, 0).color(color[0], color[1], color[2], color[3]).endVertex();
		buffer.pos(aabb.maxX, aabb.maxY, aabb.minZ).tex(1, 0).color(color[0], color[1], color[2], color[3]).endVertex();
		buffer.pos(aabb.maxX, aabb.maxY, aabb.maxZ).tex(1, 1).color(color[0], color[1], color[2], color[3]).endVertex();

		tessellator.draw();
	}
	else if(facing == EnumFacing.DOWN)
	{
		buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
		buffer.pos(aabb.minX, aabb.minY, aabb.minZ).color(color[0], color[1], color[2], color[3]).endVertex();
		buffer.pos(aabb.maxX, aabb.minY, aabb.minZ).color(color[0], color[1], color[2], color[3]).endVertex();
		buffer.pos(aabb.maxX, aabb.minY, aabb.maxZ).color(color[0], color[1], color[2], color[3]).endVertex();
		buffer.pos(aabb.minX, aabb.minY, aabb.maxZ).color(color[0], color[1], color[2], color[3]).endVertex();
		tessellator.draw();
	}
	else if(facing == EnumFacing.WEST)
	{
		buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
		buffer.pos(aabb.minX, aabb.minY, aabb.minZ).color(color[0], color[1], color[2], color[3]).endVertex();
		buffer.pos(aabb.minX, aabb.maxY, aabb.minZ).color(color[0], color[1], color[2], color[3]).endVertex();
		buffer.pos(aabb.minX, aabb.maxY, aabb.maxZ).color(color[0], color[1], color[2], color[3]).endVertex();
		buffer.pos(aabb.minX, aabb.minY, aabb.maxZ).color(color[0], color[1], color[2], color[3]).endVertex();
		tessellator.draw();
	}
	else if(facing == EnumFacing.EAST)
	{
		buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
		buffer.pos(aabb.maxX, aabb.minY, aabb.maxZ).color(color[0], color[1], color[2], color[3]).endVertex();
		buffer.pos(aabb.maxX, aabb.maxY, aabb.maxZ).color(color[0], color[1], color[2], color[3]).endVertex();
		buffer.pos(aabb.maxX, aabb.maxY, aabb.minZ).color(color[0], color[1], color[2], color[3]).endVertex();
		buffer.pos(aabb.maxX, aabb.minY, aabb.minZ).color(color[0], color[1], color[2], color[3]).endVertex();
		tessellator.draw();
	}
	else if(facing == EnumFacing.NORTH)
	{
		buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
		buffer.pos(aabb.minX, aabb.minY, aabb.minZ).color(color[0], color[1], color[2], color[3]).endVertex();
		buffer.pos(aabb.minX, aabb.maxY, aabb.minZ).color(color[0], color[1], color[2], color[3]).endVertex();
		buffer.pos(aabb.maxX, aabb.maxY, aabb.minZ).color(color[0], color[1], color[2], color[3]).endVertex();
		buffer.pos(aabb.maxX, aabb.minY, aabb.minZ).color(color[0], color[1], color[2], color[3]).endVertex();
		tessellator.draw();
	}
	else if(facing == EnumFacing.SOUTH)
	{
		buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
		buffer.pos(aabb.maxX, aabb.minY, aabb.maxZ).color(color[0], color[1], color[2], color[3]).endVertex();
		buffer.pos(aabb.maxX, aabb.maxY, aabb.maxZ).color(color[0], color[1], color[2], color[3]).endVertex();
		buffer.pos(aabb.minX, aabb.maxY, aabb.maxZ).color(color[0], color[1], color[2], color[3]).endVertex();
		buffer.pos(aabb.minX, aabb.minY, aabb.maxZ).color(color[0], color[1], color[2], color[3]).endVertex();
		tessellator.draw();
	}
}
 
Example 19
Source File: BlockSurgeryChamber.java    From Cyberware with MIT License 4 votes vote down vote up
@Override
public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, @Nullable Entity entityIn)
{
	EnumFacing face = state.getValue(FACING);
	boolean open = state.getValue(OPEN);
	
	if (state.getValue(HALF) == EnumChamberHalf.UPPER)
	{
		addCollisionBoxToList(pos, entityBox, collidingBoxes, top);
		if (!open || face != EnumFacing.SOUTH)
		{
			addCollisionBoxToList(pos, entityBox, collidingBoxes, south);
		}
		if (!open || face != EnumFacing.NORTH)
		{
			addCollisionBoxToList(pos, entityBox, collidingBoxes, north);
		}
		if (!open || face != EnumFacing.EAST)
		{
			addCollisionBoxToList(pos, entityBox, collidingBoxes, east);
		}
		if (!open || face != EnumFacing.WEST)
		{
			addCollisionBoxToList(pos, entityBox, collidingBoxes, west);
		}
	}
	else
	{		
		addCollisionBoxToList(pos, entityBox, collidingBoxes, bottom);
		if (!open || face != EnumFacing.SOUTH)
		{
			addCollisionBoxToList(pos, entityBox, collidingBoxes, south);
		}
		if (!open || face != EnumFacing.NORTH)
		{
			addCollisionBoxToList(pos, entityBox, collidingBoxes, north);
		}
		if (!open || face != EnumFacing.EAST)
		{
			addCollisionBoxToList(pos, entityBox, collidingBoxes, east);
		}
		if (!open || face != EnumFacing.WEST)
		{
			addCollisionBoxToList(pos, entityBox, collidingBoxes, west);
		}
	}
}
 
Example 20
Source File: WorldGenFallenTree.java    From Traverse-Legacy-1-12-2 with MIT License 4 votes vote down vote up
public boolean generate(World worldIn, Random rand, BlockPos position) {
    int num = rand.nextInt(5);
    EnumFacing orientation;
    if (num == 0) {
        orientation = EnumFacing.EAST;
        stateWood = stateWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X);
    } else if (num == 1) {
        orientation = EnumFacing.WEST;
        stateWood = stateWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X);
    } else if (num == 1) {
        orientation = EnumFacing.SOUTH;
        stateWood = stateWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z);
    } else {
        orientation = EnumFacing.NORTH;
        stateWood = stateWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z);
    }
    int i = rand.nextInt(2) + this.minTreeLength;
    boolean flag = true;

    if (position.getY() >= 1 && position.getY() + i + 1 <= worldIn.getHeight()) {
        for (int j = position.getY(); j <= position.getY() + 1 + i; ++j) {
            int k = 1;

            if (j == position.getY()) {
                k = 0;
            }

            if (j >= position.getY() + 1 + i - 2) {
                k = 2;
            }

            BlockPos.MutableBlockPos mutablePos = new BlockPos.MutableBlockPos();

            for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l) {
                for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1) {
                    if (j >= 0 && j < worldIn.getHeight()) {
                        if (!this.isReplaceable(worldIn, mutablePos.setPos(l, j, i1))) {
                            flag = false;
                        }
                    } else {
                        flag = false;
                    }
                }
            }
        }

        if (!flag) {
            return false;
        } else {
            IBlockState state = worldIn.getBlockState(position.down());

            if (state.getBlock().canSustainPlant(state, worldIn, position.down(), net.minecraft.util.EnumFacing.UP, (net.minecraft.block.BlockSapling) Blocks.SAPLING) && position.getY() < worldIn.getHeight() - i - 1) {
                state.getBlock().onPlantGrow(state, worldIn, position.down(), position);

                for (int j3 = 0; j3 < i; ++j3) {
                    BlockPos offsetPos = position.offset(orientation, j3);
                    state = worldIn.getBlockState(offsetPos);

                    if (state.getBlock().isAir(state, worldIn, offsetPos) || state.getBlock().isLeaves(state, worldIn, offsetPos) || state.getMaterial() == Material.VINE) {
                        this.setBlockAndNotifyAdequately(worldIn, position.offset(orientation, j3), this.stateWood);
                    }
                }
                return true;
            } else {
                return false;
            }
        }
    } else {
        return false;
    }
}