Search in sources :

Example 61 with BlockPos

use of net.minecraft.util.math.BlockPos in project NetherEx by LogicTechCorp.

the class WorldGenThornstalk method generate.

public boolean generate(World world, Random rand, BlockPos pos) {
    for (int i = 0; i < 64; ++i) {
        BlockPos newPos = pos.add(rand.nextInt(8) - rand.nextInt(8), rand.nextInt(4) - rand.nextInt(4), rand.nextInt(8) - rand.nextInt(8));
        Block blockDown = world.getBlockState(newPos.down()).getBlock();
        if (blockDown == Blocks.SOUL_SAND && NetherExBlocks.PLANT_THORNSTALK.canPlaceBlockAt(world, newPos)) {
            NetherExBlocks.PLANT_THORNSTALK.generate(world, rand, newPos);
        }
    }
    return true;
}
Also used : Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos)

Example 62 with BlockPos

use of net.minecraft.util.math.BlockPos in project NetherEx by LogicTechCorp.

the class WorldGenCeilingStructure method generate.

@Override
public boolean generate(World world, Random rand, BlockPos pos) {
    rand = world.getChunkFromBlockCoords(pos).getRandomWithSeed(world.getSeed());
    Mirror[] mirrors = Mirror.values();
    Rotation[] rotations = Rotation.values();
    Mirror mirror = mirrors[rand.nextInt(mirrors.length)];
    Rotation rotation = rotations[rand.nextInt(rotations.length)];
    MinecraftServer server = world.getMinecraftServer();
    TemplateManager manager = world.getSaveHandler().getStructureTemplateManager();
    Template template = manager.getTemplate(server, WeightedUtil.getRandomStructure(rand, variants));
    PlacementSettings placementSettings = new PlacementSettings().setMirror(mirror).setRotation(rotation).setReplacedBlock(Blocks.STRUCTURE_VOID).setRandom(rand);
    BlockPos structureSize = Template.transformedBlockPos(placementSettings, template.getSize());
    BlockPos newPos = new BlockPos(pos.getX() - structureSize.getX() / 2, 48, pos.getZ() - structureSize.getZ() / 2);
    BlockPos spawnPos = WorldGenUtil.getSuitableCeilingPos(world, newPos, structureSize);
    if (!spawnPos.equals(BlockPos.ORIGIN)) {
        WorldGenUtil.generateStructure(world, spawnPos, rand, template, placementSettings, lootTables, spawnerMobs);
        return true;
    }
    return false;
}
Also used : TemplateManager(net.minecraft.world.gen.structure.template.TemplateManager) BlockPos(net.minecraft.util.math.BlockPos) PlacementSettings(net.minecraft.world.gen.structure.template.PlacementSettings) Mirror(net.minecraft.util.Mirror) Rotation(net.minecraft.util.Rotation) MinecraftServer(net.minecraft.server.MinecraftServer) Template(net.minecraft.world.gen.structure.template.Template)

Example 63 with BlockPos

use of net.minecraft.util.math.BlockPos in project NetherEx by LogicTechCorp.

the class PigtificateVillageCollection method addFenceGatesAround.

private void addFenceGatesAround(BlockPos central) {
    for (int l = -16; l < 16; ++l) {
        for (int i1 = -4; i1 < 4; ++i1) {
            for (int j1 = -16; j1 < 16; ++j1) {
                BlockPos blockpos = central.add(l, i1, j1);
                EnumFacing outside = getOutside(blockpos);
                if (outside != null) {
                    VillageFenceGateInfo villagefenceGateinfo = checkFenceGateExistence(blockpos);
                    if (villagefenceGateinfo == null) {
                        addToNewFenceGatesList(blockpos, outside);
                    } else {
                        villagefenceGateinfo.setLastActivityTimestamp(tickCounter);
                    }
                }
            }
        }
    }
}
Also used : EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos)

Example 64 with BlockPos

use of net.minecraft.util.math.BlockPos in project NetherEx by LogicTechCorp.

the class ChunkProviderNether method populate.

@Override
public void populate(int chunkX, int chunkZ) {
    boolean logCascadingWorldGeneration = ForgeModContainer.logCascadingWorldGeneration;
    ForgeModContainer.logCascadingWorldGeneration = false;
    ChunkPos chunkPos = new ChunkPos(chunkX, chunkZ);
    BlockPos blockPos = new BlockPos(chunkX * 16, 0, chunkZ * 16);
    Biome biome = world.getBiomeForCoordsBody(blockPos.add(16, 0, 16));
    BlockFalling.fallInstantly = true;
    netherBridge.generateStructure(world, rand, chunkPos);
    biome.decorate(world, rand, blockPos);
    BlockFalling.fallInstantly = false;
    ForgeModContainer.logCascadingWorldGeneration = logCascadingWorldGeneration;
}
Also used : Biome(net.minecraft.world.biome.Biome) ChunkPos(net.minecraft.util.math.ChunkPos) BlockPos(net.minecraft.util.math.BlockPos)

Example 65 with BlockPos

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

the class DimensionInformation method writeToNBT.

public void writeToNBT(NBTTagCompound tagCompound) {
    tagCompound.setString("name", getName());
    tagCompound.setString("owner", ownerName);
    if (owner != null) {
        tagCompound.setLong("ownerM", owner.getMostSignificantBits());
        tagCompound.setLong("ownerL", owner.getLeastSignificantBits());
    }
    BlockPos spawnPoint = getSpawnPoint();
    if (spawnPoint != null) {
        BlockPosTools.writeToNBT(tagCompound, "spawnPoint", spawnPoint);
    }
    tagCompound.setInteger("probeCounter", getProbeCounter());
    // Version number so that we can detect incompatible changes in persisted dimension information objects.
    tagCompound.setInteger("version", 1);
    tagCompound.setInteger("terrain", terrainType == null ? TerrainType.TERRAIN_VOID.ordinal() : terrainType.ordinal());
    tagCompound.setIntArray("features", toIntArray(featureTypes));
    tagCompound.setIntArray("structures", toIntArray(structureTypes));
    tagCompound.setIntArray("effects", toIntArray(effectTypes));
    List<Integer> c = new ArrayList<Integer>(biomes.size());
    for (Biome t : biomes) {
        if (t != null) {
            c.add(Biome.getIdForBiome(t));
        } else {
            c.add(Biome.getIdForBiome(Biomes.PLAINS));
        }
    }
    tagCompound.setIntArray("biomes", ArrayUtils.toPrimitive(c.toArray(new Integer[c.size()])));
    tagCompound.setInteger("controller", controllerType == null ? ControllerType.CONTROLLER_DEFAULT.ordinal() : controllerType.ordinal());
    tagCompound.setString("digits", digitString);
    tagCompound.setLong("forcedSeed", forcedDimensionSeed);
    tagCompound.setLong("baseSeed", baseSeed);
    tagCompound.setInteger("worldVersion", worldVersion);
    setBlockMeta(tagCompound, baseBlockForTerrain, "baseBlock");
    setBlockMeta(tagCompound, tendrilBlock, "tendrilBlock");
    writeBlocksToNBT(tagCompound, pyramidBlocks, "pyramidBlocks");
    writeBlocksToNBT(tagCompound, sphereBlocks, "sphereBlocks");
    if (sphereBlocks.length > 0) {
        // Write out a single sphere block for compatibility with older RFTools.
        setBlockMeta(tagCompound, sphereBlocks[0], "sphereBlock");
    }
    writeBlocksToNBT(tagCompound, hugeSphereBlocks, "hugeSphereBlocks");
    writeBlocksToNBT(tagCompound, scatteredSphereBlocks, "scatteredSphereBlocks");
    writeBlocksToNBT(tagCompound, hugeLiquidSphereBlocks, "hugeLiquidSphereBlocks");
    writeFluidsToNBT(tagCompound, hugeLiquidSphereFluids, "hugeLiquidSphereFluids");
    writeBlocksToNBT(tagCompound, liquidSphereBlocks, "liquidSphereBlocks");
    if (liquidSphereBlocks.length > 0) {
        // Write out a single sphere block for compatibility with older RFTools.
        setBlockMeta(tagCompound, liquidSphereBlocks[0], "liquidSphereBlock");
    }
    writeFluidsToNBT(tagCompound, liquidSphereFluids, "liquidSphereFluids");
    if (liquidSphereFluids.length > 0) {
        tagCompound.setInteger("liquidSphereFluid", Block.REGISTRY.getIDForObject(liquidSphereFluids[0]));
    }
    setBlockMeta(tagCompound, canyonBlock, "canyonBlock");
    tagCompound.setInteger("fluidBlock", Block.REGISTRY.getIDForObject(fluidForTerrain));
    writeBlocksToNBT(tagCompound, extraOregen, "extraOregen");
    writeFluidsToNBT(tagCompound, fluidsForLakes, "lakeFluids");
    tagCompound.setBoolean("peaceful", peaceful);
    tagCompound.setBoolean("noanimals", noanimals);
    tagCompound.setBoolean("shelter", shelter);
    tagCompound.setBoolean("respawnHere", respawnHere);
    tagCompound.setBoolean("cheater", cheater);
    if (celestialAngle != null) {
        tagCompound.setFloat("celestialAngle", celestialAngle);
    }
    if (timeSpeed != null) {
        tagCompound.setFloat("timeSpeed", timeSpeed);
    }
    tagCompound.setInteger("probes", probeCounter);
    tagCompound.setInteger("actualCost", actualRfCost);
    skyDescriptor.writeToNBT(tagCompound);
    weatherDescriptor.writeToNBT(tagCompound);
    tagCompound.setLong("patreon1", patreon1);
    NBTTagList list = new NBTTagList();
    for (MobDescriptor mob : extraMobs) {
        NBTTagCompound tc = new NBTTagCompound();
        if (mob != null) {
            if (mob.getEntityClass() != null) {
                tc.setString("class", mob.getEntityClass().getName());
                tc.setInteger("chance", mob.getSpawnChance());
                tc.setInteger("minGroup", mob.getMinGroup());
                tc.setInteger("maxGroup", mob.getMaxGroup());
                tc.setInteger("maxLoaded", mob.getMaxLoaded());
                list.appendTag(tc);
            }
        }
    }
    tagCompound.setTag("mobs", list);
    tagCompound.setString("dimensionTypes", StringUtils.join(dimensionTypes, ","));
}
Also used : Biome(net.minecraft.world.biome.Biome) 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