Search in sources :

Example 86 with EnumFacing

use of net.minecraft.util.EnumFacing in project MorePlanets by SteveKunG.

the class BlockCheeseSporeChest method getLockableContainer.

@Override
public ILockableContainer getLockableContainer(World world, BlockPos pos) {
    TileEntity tileentity = world.getTileEntity(pos);
    if (!(tileentity instanceof TileEntityCheeseSporeChest)) {
        return null;
    } else {
        Object object = tileentity;
        if (this.isBlocked(world, pos)) {
            return null;
        } else {
            Iterator iterator = EnumFacing.Plane.HORIZONTAL.iterator();
            while (iterator.hasNext()) {
                EnumFacing enumfacing = (EnumFacing) iterator.next();
                BlockPos blockpos1 = pos.offset(enumfacing);
                Block block = world.getBlockState(blockpos1).getBlock();
                if (block == this) {
                    if (this.isBlocked(world, blockpos1)) {
                        return null;
                    }
                    TileEntity tileentity1 = world.getTileEntity(blockpos1);
                    if (tileentity1 instanceof TileEntityCheeseSporeChest) {
                        if (enumfacing != EnumFacing.WEST && enumfacing != EnumFacing.NORTH) {
                            object = new InventoryLargeChest(GCCoreUtil.translate("container.chestDouble"), (ILockableContainer) object, (TileEntityCheeseSporeChest) tileentity1);
                        } else {
                            object = new InventoryLargeChest(GCCoreUtil.translate("container.chestDouble"), (TileEntityCheeseSporeChest) tileentity1, (ILockableContainer) object);
                        }
                    }
                }
            }
            return (ILockableContainer) object;
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ILockableContainer(net.minecraft.world.ILockableContainer) TileEntityCheeseSporeChest(stevekung.mods.moreplanets.module.planets.chalos.tileentity.TileEntityCheeseSporeChest) InventoryLargeChest(net.minecraft.inventory.InventoryLargeChest) EnumFacing(net.minecraft.util.EnumFacing) Iterator(java.util.Iterator) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos)

Example 87 with EnumFacing

use of net.minecraft.util.EnumFacing in project MorePlanets by SteveKunG.

the class WorldGenSpaceDungeons method generate.

@Override
public boolean generate(World world, Random rand, BlockPos pos) {
    int i = rand.nextInt(2) + 2;
    int j = -i - 1;
    int k = i + 1;
    int l = rand.nextInt(2) + 2;
    int i1 = -l - 1;
    int j1 = l + 1;
    int k1 = 0;
    int l1;
    int i2;
    int j2;
    BlockPos blockpos1;
    for (l1 = j; l1 <= k; ++l1) {
        for (i2 = -1; i2 <= 4; ++i2) {
            for (j2 = i1; j2 <= j1; ++j2) {
                blockpos1 = pos.add(l1, i2, j2);
                Material material = world.getBlockState(blockpos1).getMaterial();
                boolean flag3 = material.isSolid();
                if (i2 == -1 && !flag3) {
                    return false;
                }
                if (i2 == 4 && !flag3) {
                    return false;
                }
                if ((l1 == j || l1 == k || j2 == i1 || j2 == j1) && i2 == 0 && world.isAirBlock(blockpos1) && world.isAirBlock(blockpos1.up())) {
                    ++k1;
                }
            }
        }
    }
    if (k1 >= 1 && k1 <= 5) {
        for (l1 = j; l1 <= k; ++l1) {
            for (i2 = 3; i2 >= -1; --i2) {
                for (j2 = i1; j2 <= j1; ++j2) {
                    blockpos1 = pos.add(l1, i2, j2);
                    if (l1 != j && i2 != -1 && j2 != i1 && l1 != k && i2 != 4 && j2 != j1) {
                        if (world.getBlockState(blockpos1).getBlock() != this.chest) {
                            world.setBlockToAir(blockpos1);
                        }
                    } else if (blockpos1.getY() >= 0 && !world.getBlockState(blockpos1.down()).getMaterial().isSolid()) {
                        world.setBlockToAir(blockpos1);
                    } else if (world.getBlockState(blockpos1).getMaterial().isSolid() && world.getBlockState(blockpos1).getBlock() != this.chest) {
                        if (i2 == -1 && rand.nextInt(4) != 0) {
                            world.setBlockState(blockpos1, this.moss.getStateFromMeta(this.mossMeta), 2);
                        } else {
                            world.setBlockState(blockpos1, this.cobblestone.getStateFromMeta(this.cobbleMeta), 2);
                        }
                    }
                }
            }
        }
        l1 = 0;
        while (l1 < 2) {
            i2 = 0;
            while (true) {
                if (i2 < 3) {
                    label100: {
                        j2 = pos.getX() + rand.nextInt(i * 2 + 1) - i;
                        int l2 = pos.getY();
                        int i3 = pos.getZ() + rand.nextInt(l * 2 + 1) - l;
                        BlockPos blockpos2 = new BlockPos(j2, l2, i3);
                        if (world.isAirBlock(blockpos2)) {
                            int k2 = 0;
                            Iterator iterator = EnumFacing.Plane.HORIZONTAL.iterator();
                            while (iterator.hasNext()) {
                                EnumFacing enumfacing = (EnumFacing) iterator.next();
                                if (world.getBlockState(blockpos2.offset(enumfacing)).getMaterial().isSolid()) {
                                    ++k2;
                                }
                            }
                            if (k2 == 1) {
                                world.setBlockState(blockpos2, ((BlockAncientChestMP) this.chest).correctFacing(world, blockpos2, this.chest.getDefaultState()), 2);
                                TileEntity tileentity1 = world.getTileEntity(blockpos2);
                                if (tileentity1 instanceof TileEntityAncientChestMP) {
                                    ((TileEntityAncientChestMP) tileentity1).setLootTable(MPLootTables.COMMON_SPACE_DUNGEON, rand.nextLong());
                                }
                                break label100;
                            }
                        }
                        ++i2;
                        continue;
                    }
                }
                ++l1;
                break;
            }
        }
        world.setBlockState(pos, Blocks.MOB_SPAWNER.getDefaultState(), 2);
        TileEntity tileentity = world.getTileEntity(pos);
        if (tileentity instanceof TileEntityMobSpawner) {
            ((TileEntityMobSpawner) tileentity).getSpawnerBaseLogic().setEntityId(this.pickMobSpawner(rand));
        } else {
            MPLog.error("Failed to fetch mob spawner entity at x:{} y:{} z:{}", pos.getX(), pos.getY(), pos.getZ());
        }
        MPLog.debug("Generate {} spawner at: x:{} y:{} z:{}", ((TileEntityMobSpawner) tileentity).getSpawnerBaseLogic().getEntityId().toString(), pos.getX(), pos.getY(), pos.getZ());
        return true;
    } else {
        return false;
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityAncientChestMP(stevekung.mods.moreplanets.util.tileentity.TileEntityAncientChestMP) EnumFacing(net.minecraft.util.EnumFacing) Iterator(java.util.Iterator) BlockPos(net.minecraft.util.math.BlockPos) Material(net.minecraft.block.material.Material) TileEntityMobSpawner(net.minecraft.tileentity.TileEntityMobSpawner)

Example 88 with EnumFacing

use of net.minecraft.util.EnumFacing in project MorePlanets by SteveKunG.

the class ItemDoorMP method onItemUse.

@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    ItemStack itemStack = player.getHeldItem(hand);
    if (facing != EnumFacing.UP) {
        return EnumActionResult.FAIL;
    } else {
        IBlockState iblockstate = world.getBlockState(pos);
        Block block = iblockstate.getBlock();
        if (!block.isReplaceable(world, pos)) {
            pos = pos.offset(facing);
        }
        if (player.canPlayerEdit(pos, facing, itemStack) && this.door.canPlaceBlockAt(world, pos)) {
            EnumFacing enumfacing = EnumFacing.fromAngle(player.rotationYaw);
            int i = enumfacing.getFrontOffsetX();
            int j = enumfacing.getFrontOffsetZ();
            boolean flag = i < 0 && hitZ < 0.5F || i > 0 && hitZ > 0.5F || j < 0 && hitX > 0.5F || j > 0 && hitX < 0.5F;
            ItemDoor.placeDoor(world, pos, enumfacing, this.door, flag);
            SoundType soundtype = world.getBlockState(pos).getBlock().getSoundType(world.getBlockState(pos), world, pos, player);
            world.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
            itemStack.shrink(1);
            return EnumActionResult.SUCCESS;
        } else {
            return EnumActionResult.FAIL;
        }
    }
}
Also used : SoundType(net.minecraft.block.SoundType) IBlockState(net.minecraft.block.state.IBlockState) EnumFacing(net.minecraft.util.EnumFacing) Block(net.minecraft.block.Block) ItemStack(net.minecraft.item.ItemStack)

Example 89 with EnumFacing

use of net.minecraft.util.EnumFacing in project MorePlanets by SteveKunG.

the class DoubleAncientChestItemHandlerMP method get.

public static DoubleAncientChestItemHandlerMP get(TileEntityAncientChestMP chest) {
    World world = chest.getWorld();
    BlockPos pos = chest.getPos();
    if (world == null || pos == null || !world.isBlockLoaded(pos)) {
        return null;
    }
    Block blockType = chest.getBlockType();
    EnumFacing[] horizontals = EnumFacing.HORIZONTALS;
    for (int i = horizontals.length - 1; i >= 0; i--) {
        EnumFacing enumfacing = horizontals[i];
        BlockPos blockpos = pos.offset(enumfacing);
        Block block = world.getBlockState(blockpos).getBlock();
        if (block == blockType) {
            TileEntity otherTE = world.getTileEntity(blockpos);
            if (otherTE instanceof TileEntityAncientChestMP) {
                TileEntityAncientChestMP otherChest = (TileEntityAncientChestMP) otherTE;
                return new DoubleAncientChestItemHandlerMP(chest, otherChest, enumfacing != net.minecraft.util.EnumFacing.WEST && enumfacing != net.minecraft.util.EnumFacing.NORTH);
            }
        }
    }
    return NO_ADJACENT_CHESTS_INSTANCE;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityAncientChestMP(stevekung.mods.moreplanets.util.tileentity.TileEntityAncientChestMP) EnumFacing(net.minecraft.util.EnumFacing) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World)

Example 90 with EnumFacing

use of net.minecraft.util.EnumFacing in project SpongeCommon by SpongePowered.

the class PoweredPropertyStore method getFor.

@Override
public Optional<PoweredProperty> getFor(Location<World> location, Direction direction) {
    final net.minecraft.world.World world = (net.minecraft.world.World) location.getExtent();
    final EnumFacing facing = toEnumFacing(direction);
    final boolean powered = world.getStrongPower(VecHelper.toBlockPos(location).offset(facing), facing) > 0;
    return Optional.of(powered ? TRUE : FALSE);
}
Also used : EnumFacing(net.minecraft.util.EnumFacing) World(org.spongepowered.api.world.World)

Aggregations

EnumFacing (net.minecraft.util.EnumFacing)1673 BlockPos (net.minecraft.util.math.BlockPos)491 IBlockState (net.minecraft.block.state.IBlockState)403 TileEntity (net.minecraft.tileentity.TileEntity)392 ItemStack (net.minecraft.item.ItemStack)192 Block (net.minecraft.block.Block)158 ArrayList (java.util.ArrayList)121 World (net.minecraft.world.World)114 Vec3d (net.minecraft.util.math.Vec3d)104 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)98 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)88 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)73 EntityPlayer (net.minecraft.entity.player.EntityPlayer)65 FluidStack (net.minecraftforge.fluids.FluidStack)65 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)63 Nullable (javax.annotation.Nullable)51 List (java.util.List)48 Nonnull (javax.annotation.Nonnull)47 HashSet (java.util.HashSet)43 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)43