Search in sources :

Example 91 with BlockPos

use of net.minecraft.util.math.BlockPos in project RFToolsDimensions by McJty.

the class GenericWorldGenerator method addOreSpawn.

public void addOreSpawn(IBlockState block, IBlockState targetBlock, World world, Random random, int blockXPos, int blockZPos, int minVeinSize, int maxVeinSize, int chancesToSpawn, int minY, int maxY) {
    WorldGenMinable minable = new WorldGenMinable(block, (minVeinSize - random.nextInt(maxVeinSize - minVeinSize)), p -> p == targetBlock);
    for (int i = 0; i < chancesToSpawn; i++) {
        int posX = blockXPos + random.nextInt(16);
        int posY = minY + random.nextInt(maxY - minY);
        int posZ = blockZPos + random.nextInt(16);
        minable.generate(world, random, new BlockPos(posX, posY, posZ));
    }
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) WorldGenMinable(net.minecraft.world.gen.feature.WorldGenMinable)

Example 92 with BlockPos

use of net.minecraft.util.math.BlockPos in project RFToolsDimensions by McJty.

the class GenericWorldGenerator method generateLootSpawners.

private void generateLootSpawners(Random random, int chunkX, int chunkZ, World world) {
    BuildingInfo info = new BuildingInfo(chunkX, chunkZ, world.getSeed());
    int buildingtop = 0;
    boolean building = info.hasBuilding;
    if (building) {
        buildingtop = 69 + info.floors * 6;
    }
    int height = 63 - info.floorsBelowGround * 6;
    while (height < buildingtop) {
        int f = LostCitiesTerrainGenerator.getFloor(height);
        if (f == 0) {
            BlockPos floorpos = new BlockPos(chunkX * 16, height, chunkZ * 16);
            int floortype = info.floorTypes[LostCitiesTerrainGenerator.getLevel(height) + info.floorsBelowGround];
            GenInfo getInfo = LostCitiesTerrainGenerator.getGenInfos().get(Pair.of(info.getGenInfoIndex(), floortype));
            for (BlockPos p : getInfo.getChest()) {
                BlockPos pos = floorpos.add(p);
                if (!world.isAirBlock(pos)) {
                    createLootChest(random, world, pos);
                }
            }
            for (BlockPos p : getInfo.getRandomFeatures()) {
                BlockPos pos = floorpos.add(p);
                if (!world.isAirBlock(pos)) {
                    createRandomFeature(random, world, pos);
                }
            }
            for (BlockPos p : getInfo.getModularStorages()) {
                BlockPos pos = floorpos.add(p);
                if (!world.isAirBlock(pos)) {
                    createModularStorage(random, world, pos);
                }
            }
            for (BlockPos p : getInfo.getRandomRFToolsMachines()) {
                BlockPos pos = floorpos.add(p);
                if (!world.isAirBlock(pos)) {
                    createRFToolsMachine(random, world, pos);
                }
            }
            for (Map.Entry<BlockPos, Integer> entry : getInfo.getSpawnerType().entrySet()) {
                BlockPos pos = floorpos.add(entry.getKey());
                if (!world.isAirBlock(pos)) {
                    world.setBlockState(pos, Blocks.MOB_SPAWNER.getDefaultState());
                    TileEntity tileentity = world.getTileEntity(pos);
                    if (tileentity instanceof TileEntityMobSpawner) {
                        TileEntityMobSpawner spawner = (TileEntityMobSpawner) tileentity;
                        switch(entry.getValue()) {
                            case 1:
                                EntityTools.setSpawnerEntity(world, spawner, new ResourceLocation("minecraft:zombie"), "Zombie");
                                break;
                            case 2:
                                EntityTools.setSpawnerEntity(world, spawner, new ResourceLocation("minecraft:skeleton"), "Skeleton");
                                break;
                            case 3:
                                EntityTools.setSpawnerEntity(world, spawner, new ResourceLocation("minecraft:spider"), "Spider");
                                break;
                            case 4:
                                EntityTools.setSpawnerEntity(world, spawner, new ResourceLocation("minecraft:blaze"), "Blaze");
                                break;
                        }
                    }
                }
            }
        }
        height++;
    }
}
Also used : ModularStorageTileEntity(mcjty.rftools.blocks.storage.ModularStorageTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) BuildingInfo(mcjty.rftoolsdim.dimensions.world.terrain.lost.BuildingInfo) ResourceLocation(net.minecraft.util.ResourceLocation) BlockPos(net.minecraft.util.math.BlockPos) GenInfo(mcjty.rftoolsdim.dimensions.world.terrain.lost.GenInfo) TileEntityMobSpawner(net.minecraft.tileentity.TileEntityMobSpawner) Map(java.util.Map)

Example 93 with BlockPos

use of net.minecraft.util.math.BlockPos in project ImmersiveEngineering by BluSunrize.

the class TileEntityDieselGenerator method update.

@Override
public void update() {
    super.update();
    if (isDummy())
        return;
    if (active || animation_fanFadeIn > 0 || animation_fanFadeOut > 0) {
        float base = 18f;
        float step = active ? base : 0;
        if (animation_fanFadeIn > 0) {
            step -= (animation_fanFadeIn / 80f) * base;
            animation_fanFadeIn--;
        }
        if (animation_fanFadeOut > 0) {
            step += (animation_fanFadeOut / 80f) * base;
            animation_fanFadeOut--;
        }
        animation_fanRotationStep = step;
        animation_fanRotation += step;
        animation_fanRotation %= 360;
    }
    if (worldObj.isRemote) {
        ImmersiveEngineering.proxy.handleTileSound(IESounds.dieselGenerator, this, active, .5f, 1);
        if (active && worldObj.getTotalWorldTime() % 4 == 0) {
            BlockPos exhaust = this.getBlockPosForPos(38);
            EnumFacing fl = facing;
            EnumFacing fw = facing.rotateY();
            if (mirrored)
                fw = fw.getOpposite();
            worldObj.spawnParticle(EnumParticleTypes.SMOKE_LARGE, exhaust.getX() + .5 + (fl.getFrontOffsetX() * .3125f) + (-fw.getFrontOffsetX() * .3125f), exhaust.getY() + 1.25, exhaust.getZ() + .5 + (fl.getFrontOffsetZ() * .3125f) + (-fw.getFrontOffsetZ() * .3125f), 0, 0, 0);
        }
    } else {
        boolean prevActive = active;
        if (!isRSDisabled() && tanks[0].getFluid() != null && tanks[0].getFluid().getFluid() != null) {
            int burnTime = DieselHandler.getBurnTime(tanks[0].getFluid().getFluid());
            if (burnTime > 0) {
                int fluidConsumed = 1000 / burnTime;
                int output = IEConfig.Machines.dieselGen_output;
                int connected = 0;
                TileEntity[] receivers = new TileEntity[3];
                for (int i = 0; i < 3; i++) {
                    receivers[i] = getEnergyOutput(i == 1 ? -1 : i == 2 ? 1 : 0);
                    if (receivers[i] != null) {
                        if (EnergyHelper.insertFlux(receivers[i], EnumFacing.DOWN, 4096, true) > 0)
                            connected++;
                    }
                }
                if (connected > 0 && tanks[0].getFluidAmount() >= fluidConsumed) {
                    if (!active) {
                        active = true;
                        animation_fanFadeIn = 80;
                    }
                    tanks[0].drain(fluidConsumed, true);
                    int splitOutput = output / connected;
                    int leftover = output % connected;
                    for (int i = 0; i < 3; i++) if (receivers[i] != null)
                        EnergyHelper.insertFlux(receivers[i], EnumFacing.DOWN, splitOutput + (leftover-- > 0 ? 1 : 0), false);
                } else if (active) {
                    active = false;
                    animation_fanFadeOut = 80;
                }
            }
        } else if (active) {
            active = false;
            animation_fanFadeOut = 80;
        }
        if (prevActive != active) {
            this.markDirty();
            this.markContainingBlockForUpdate(null);
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos)

Example 94 with BlockPos

use of net.minecraft.util.math.BlockPos in project ImmersiveEngineering by BluSunrize.

the class TileEntityAssembler method doProcessOutput.

@Override
public void doProcessOutput(ItemStack output) {
    BlockPos pos = getPos().offset(facing, -1);
    TileEntity inventoryTile = this.worldObj.getTileEntity(pos);
    if (inventoryTile != null)
        output = Utils.insertStackIntoInventory(inventoryTile, output, facing.getOpposite());
    if (output != null)
        Utils.dropStackAtPos(worldObj, pos, output, facing);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) BlockPos(net.minecraft.util.math.BlockPos)

Example 95 with BlockPos

use of net.minecraft.util.math.BlockPos in project ImmersiveEngineering by BluSunrize.

the class TileEntityExcavator method disassemble.

@Override
public void disassemble() {
    super.disassemble();
    BlockPos wheelPos = this.getBlockPosForPos(31);
    TileEntity center = worldObj.getTileEntity(wheelPos);
    if (center instanceof TileEntityBucketWheel)
        worldObj.addBlockEvent(center.getPos(), center.getBlockType(), 0, 0);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) BlockPos(net.minecraft.util.math.BlockPos)

Aggregations

BlockPos (net.minecraft.util.math.BlockPos)864 IBlockState (net.minecraft.block.state.IBlockState)220 TileEntity (net.minecraft.tileentity.TileEntity)135 Block (net.minecraft.block.Block)103 EnumFacing (net.minecraft.util.EnumFacing)95 ItemStack (net.minecraft.item.ItemStack)81 World (net.minecraft.world.World)77 EntityPlayer (net.minecraft.entity.player.EntityPlayer)54 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)46 Vec3d (net.minecraft.util.math.Vec3d)44 NotNull (org.jetbrains.annotations.NotNull)44 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)38 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)31 Entity (net.minecraft.entity.Entity)30 PhysicsWrapperEntity (ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity)29 Nullable (org.jetbrains.annotations.Nullable)26 ArrayList (java.util.ArrayList)23 EntityLivingBase (net.minecraft.entity.EntityLivingBase)23 WorldServer (net.minecraft.world.WorldServer)23 TextComponentString (net.minecraft.util.text.TextComponentString)22