Search in sources :

Example 11 with EnumFacing

use of net.minecraft.util.EnumFacing in project ImmersiveEngineering by BluSunrize.

the class ConveyorSplit method handleInsertion.

@Override
public void handleInsertion(TileEntity tile, EntityItem entity, EnumFacing facing, ConveyorDirection conDir, double distX, double distZ) {
    String nbtKey = "immersiveengineering:conveyorDir" + Integer.toHexString(tile.getPos().hashCode());
    if (entity.getEntityData().hasKey(nbtKey)) {
        EnumFacing redirect = EnumFacing.values()[entity.getEntityData().getInteger(nbtKey)];
        BlockPos nextPos = tile.getPos().offset(redirect);
        double distNext = Math.abs((redirect.getAxis() == Axis.Z ? nextPos.getZ() : nextPos.getX()) + .5 - (redirect.getAxis() == Axis.Z ? entity.posZ : entity.posX));
        if (distNext < .7)
            super.handleInsertion(tile, entity, redirect, conDir, distX, distZ);
    }
}
Also used : EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos)

Example 12 with EnumFacing

use of net.minecraft.util.EnumFacing in project ImmersiveEngineering by BluSunrize.

the class MultiblockBlastFurnace method createStructure.

@Override
public boolean createStructure(World world, BlockPos pos, EnumFacing side, EntityPlayer player) {
    EnumFacing f = EnumFacing.fromAngle(player.rotationYaw);
    pos = pos.offset(f);
    for (int h = -1; h <= 1; h++) for (int xx = -1; xx <= 1; xx++) for (int zz = -1; zz <= 1; zz++) {
        if (!Utils.isBlockAt(world, pos.add(xx, h, zz), IEContent.blockStoneDecoration, BlockTypes_StoneDecoration.BLASTBRICK.getMeta()))
            return false;
    }
    for (int h = -1; h <= 1; h++) for (int l = -1; l <= 1; l++) for (int w = -1; w <= 1; w++) {
        int xx = f == EnumFacing.EAST ? l : f == EnumFacing.WEST ? -l : f == EnumFacing.NORTH ? -w : w;
        int zz = f == EnumFacing.NORTH ? l : f == EnumFacing.SOUTH ? -l : f == EnumFacing.EAST ? w : -w;
        BlockPos pos2 = pos.add(xx, h, zz);
        world.setBlockState(pos2, IEContent.blockStoneDevice.getStateFromMeta(1));
        TileEntity curr = world.getTileEntity(pos2);
        if (curr instanceof TileEntityBlastFurnace) {
            TileEntityBlastFurnace currBlast = (TileEntityBlastFurnace) curr;
            currBlast.offset = new int[] { xx, h, zz };
            currBlast.pos = (h + 1) * 9 + (l + 1) * 3 + (w + 1);
            currBlast.facing = f.getOpposite();
            currBlast.formed = true;
            currBlast.markDirty();
            world.addBlockEvent(pos2, IEContent.blockStoneDevice, 255, 0);
        }
    }
    player.addStat(IEAchievements.blastfurnace);
    return true;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) EnumFacing(net.minecraft.util.EnumFacing) TileEntityBlastFurnace(blusunrize.immersiveengineering.common.blocks.stone.TileEntityBlastFurnace) BlockPos(net.minecraft.util.math.BlockPos)

Example 13 with EnumFacing

use of net.minecraft.util.EnumFacing in project ImmersiveEngineering by BluSunrize.

the class MultiblockCokeOven method createStructure.

@Override
public boolean createStructure(World world, BlockPos pos, EnumFacing side, EntityPlayer player) {
    EnumFacing f = EnumFacing.fromAngle(player.rotationYaw);
    pos = pos.offset(f);
    for (int h = -1; h <= 1; h++) for (int xx = -1; xx <= 1; xx++) for (int zz = -1; zz <= 1; zz++) {
        if (!Utils.isBlockAt(world, pos.add(xx, h, zz), IEContent.blockStoneDecoration, BlockTypes_StoneDecoration.COKEBRICK.getMeta()))
            return false;
    }
    for (int h = -1; h <= 1; h++) for (int l = -1; l <= 1; l++) for (int w = -1; w <= 1; w++) {
        int xx = f == EnumFacing.EAST ? l : f == EnumFacing.WEST ? -l : f == EnumFacing.NORTH ? -w : w;
        int zz = f == EnumFacing.NORTH ? l : f == EnumFacing.SOUTH ? -l : f == EnumFacing.EAST ? w : -w;
        world.setBlockState(pos.add(xx, h, zz), IEContent.blockStoneDevice.getStateFromMeta(0));
        BlockPos pos2 = pos.add(xx, h, zz);
        TileEntity curr = world.getTileEntity(pos2);
        if (curr instanceof TileEntityCokeOven) {
            TileEntityCokeOven currBlast = (TileEntityCokeOven) curr;
            currBlast.offset = new int[] { xx, h, zz };
            currBlast.pos = (h + 1) * 9 + (l + 1) * 3 + (w + 1);
            currBlast.facing = f.getOpposite();
            currBlast.formed = true;
            currBlast.markDirty();
            world.addBlockEvent(pos2, IEContent.blockStoneDevice, 255, 0);
        }
    }
    return true;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityCokeOven(blusunrize.immersiveengineering.common.blocks.stone.TileEntityCokeOven) EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos)

Example 14 with EnumFacing

use of net.minecraft.util.EnumFacing in project ImmersiveEngineering by BluSunrize.

the class MultiblockSheetmetalTank method createStructure.

@Override
public boolean createStructure(World world, BlockPos pos, EnumFacing side, EntityPlayer player) {
    EnumFacing f = EnumFacing.fromAngle(player.rotationYaw);
    pos = pos.offset(f);
    if (!(Utils.isOreBlockAt(world, pos.offset(f, -1).offset(f.rotateY()), "fenceTreatedWood") && Utils.isOreBlockAt(world, pos.offset(f, -1).offset(f.rotateYCCW()), "fenceTreatedWood")))
        for (int i = 0; i < 4; i++) if (Utils.isOreBlockAt(world, pos.add(0, -i, 0).offset(f, -1).offset(f.rotateY()), "fenceTreatedWood") && Utils.isOreBlockAt(world, pos.add(0, -i, 0).offset(f, -1).offset(f.rotateYCCW()), "fenceTreatedWood")) {
            pos = pos.add(0, -i, 0);
            break;
        }
    for (int h = 0; h <= 4; h++) for (int xx = -1; xx <= 1; xx++) for (int zz = -1; zz <= 1; zz++) if (h == 0) {
        if (Math.abs(xx) == 1 && Math.abs(zz) == 1) {
            if (!Utils.isOreBlockAt(world, pos.add(xx, h, zz), "fenceTreatedWood"))
                return false;
        } else if (xx == 0 && zz == 0)
            if (!Utils.isOreBlockAt(world, pos.add(xx, h, zz), "blockSheetmetalIron"))
                return false;
    } else {
        if (h < 4 && xx == 0 && zz == 0) {
            if (!world.isAirBlock(pos.add(xx, h, zz)))
                return false;
        } else if (!Utils.isOreBlockAt(world, pos.add(xx, h, zz), "blockSheetmetalIron"))
            return false;
    }
    for (int h = 0; h <= 4; h++) for (int l = -1; l <= 1; l++) for (int w = -1; w <= 1; w++) {
        if (h == 0 && !((l == 0 && w == 0) || (Math.abs(l) == 1 && Math.abs(w) == 1)))
            continue;
        if (h > 0 && h < 4 && l == 0 && w == 0)
            continue;
        int xx = f == EnumFacing.EAST ? l : f == EnumFacing.WEST ? -l : f == EnumFacing.NORTH ? -w : w;
        int zz = f == EnumFacing.NORTH ? l : f == EnumFacing.SOUTH ? -l : f == EnumFacing.EAST ? w : -w;
        world.setBlockState(pos.add(xx, h, zz), IEContent.blockMetalMultiblock.getStateFromMeta(BlockTypes_MetalMultiblock.TANK.getMeta()));
        BlockPos pos2 = pos.add(xx, h, zz);
        TileEntity curr = world.getTileEntity(pos2);
        if (curr instanceof TileEntitySheetmetalTank) {
            TileEntitySheetmetalTank currTank = (TileEntitySheetmetalTank) curr;
            currTank.offset = new int[] { xx, h, zz };
            currTank.pos = h * 9 + (l + 1) * 3 + (w + 1);
            currTank.facing = f.getOpposite();
            currTank.formed = true;
            currTank.offset = new int[] { xx, h, zz };
            currTank.markDirty();
            world.addBlockEvent(pos2, IEContent.blockMetalMultiblock, 255, 0);
        }
    }
    return true;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos) TileEntitySheetmetalTank(blusunrize.immersiveengineering.common.blocks.metal.TileEntitySheetmetalTank)

Example 15 with EnumFacing

use of net.minecraft.util.EnumFacing in project ImmersiveEngineering by BluSunrize.

the class MultiblockSilo method createStructure.

@Override
public boolean createStructure(World world, BlockPos pos, EnumFacing side, EntityPlayer player) {
    EnumFacing f = EnumFacing.fromAngle(player.rotationYaw);
    pos = pos.offset(f);
    if (!(Utils.isOreBlockAt(world, pos.offset(f, -1).offset(f.rotateY()), "fenceTreatedWood") && Utils.isOreBlockAt(world, pos.offset(f, -1).offset(f.rotateYCCW()), "fenceTreatedWood")))
        for (int i = 0; i < 6; i++) if (Utils.isOreBlockAt(world, pos.add(0, -i, 0).offset(f, -1).offset(f.rotateY()), "fenceTreatedWood") && Utils.isOreBlockAt(world, pos.add(0, -i, 0).offset(f, -1).offset(f.rotateYCCW()), "fenceTreatedWood")) {
            pos = pos.add(0, -i, 0);
            break;
        }
    for (int h = 0; h <= 6; h++) for (int xx = -1; xx <= 1; xx++) for (int zz = -1; zz <= 1; zz++) if (h == 0) {
        if (Math.abs(xx) == 1 && Math.abs(zz) == 1) {
            if (!Utils.isOreBlockAt(world, pos.add(xx, h, zz), "fenceTreatedWood"))
                return false;
        } else if (xx == 0 && zz == 0)
            if (!Utils.isOreBlockAt(world, pos.add(xx, h, zz), "blockSheetmetalIron"))
                return false;
    } else {
        if (h < 6 && xx == 0 && zz == 0) {
            if (!world.isAirBlock(pos.add(xx, h, zz)))
                return false;
        } else if (!Utils.isOreBlockAt(world, pos.add(xx, h, zz), "blockSheetmetalIron"))
            return false;
    }
    for (int h = 0; h <= 6; h++) for (int l = -1; l <= 1; l++) for (int w = -1; w <= 1; w++) {
        if (h == 0 && !((l == 0 && w == 0) || (Math.abs(l) == 1 && Math.abs(w) == 1)))
            continue;
        if (h > 0 && h < 6 && l == 0 && w == 0)
            continue;
        int xx = f == EnumFacing.EAST ? l : f == EnumFacing.WEST ? -l : f == EnumFacing.NORTH ? -w : w;
        int zz = f == EnumFacing.NORTH ? l : f == EnumFacing.SOUTH ? -l : f == EnumFacing.EAST ? w : -w;
        world.setBlockState(pos.add(xx, h, zz), IEContent.blockMetalMultiblock.getStateFromMeta(BlockTypes_MetalMultiblock.SILO.getMeta()));
        BlockPos pos2 = pos.add(xx, h, zz);
        TileEntity curr = world.getTileEntity(pos2);
        if (curr instanceof TileEntitySilo) {
            TileEntitySilo currTank = (TileEntitySilo) curr;
            currTank.offset = new int[] { xx, h, zz };
            currTank.pos = h * 9 + (l + 1) * 3 + (w + 1);
            currTank.facing = f.getOpposite();
            currTank.formed = true;
            currTank.offset = new int[] { xx, h, zz };
            currTank.markDirty();
            world.addBlockEvent(pos2, IEContent.blockMetalMultiblock, 255, 0);
        }
    }
    player.addStat(IEAchievements.mbSilo);
    return true;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntitySilo(blusunrize.immersiveengineering.common.blocks.metal.TileEntitySilo) EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos)

Aggregations

EnumFacing (net.minecraft.util.EnumFacing)260 BlockPos (net.minecraft.util.math.BlockPos)94 TileEntity (net.minecraft.tileentity.TileEntity)64 IBlockState (net.minecraft.block.state.IBlockState)57 Block (net.minecraft.block.Block)35 ItemStack (net.minecraft.item.ItemStack)24 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)23 Vec3d (net.minecraft.util.math.Vec3d)16 ArrayList (java.util.ArrayList)15 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)10 IFluidHandler (net.minecraftforge.fluids.capability.IFluidHandler)10 World (net.minecraft.world.World)9 Tessellator (net.minecraft.client.renderer.Tessellator)8 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)8 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)7 List (java.util.List)6 EntityLivingBase (net.minecraft.entity.EntityLivingBase)6 EntityPlayer (net.minecraft.entity.player.EntityPlayer)6 IExtendedBlockState (net.minecraftforge.common.property.IExtendedBlockState)6 Nonnull (javax.annotation.Nonnull)5