net.minecraft.world.chunk.IChunkProvider Java Examples

The following examples show how to use net.minecraft.world.chunk.IChunkProvider. 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: ValkyrienSkiesWorldGen.java    From Valkyrien-Skies with Apache License 2.0 6 votes vote down vote up
@Override
public void generate(Random random, int chunkX, int chunkZ, World world,
    IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
    if (ValkyrienSkiesWorld.OREGEN_ENABLED && VSConfig.valkyriumSpawnRate > 0) {
        if (this.genValkyriumOre == null) {
            this.genValkyriumOre = new WorldGenMinable(
                ValkyrienSkiesWorld.INSTANCE.valkyriumOre.getDefaultState(), 8);
        }
        switch (world.provider.getDimension()) {
            case 0: //Overworld
                this.runValkyriumGenerator(this.genValkyriumOre, world, random, chunkX, chunkZ, VSConfig.valkyriumSpawnRate,
                    0, 25);
                // runDungeonGenerator(world, random, chunkX, chunkZ, 1);
                break;
            case -1: //Nvalkyrium
                break;
            case 1: //End
                break;
        }
    }
}
 
Example #2
Source File: WorldGenPepper.java    From Sakura_mod with MIT License 6 votes vote down vote up
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator,IChunkProvider chunkProvider) {
    int x = chunkX * 16;
    int z = chunkZ * 16;
    
    Biome biome = world.getBiomeForCoordsBody(new BlockPos(x, 0, z));
    if (BiomeDictionary.hasType(biome, BiomeDictionary.Type.DEAD)
    		||BiomeDictionary.hasType(biome, BiomeDictionary.Type.SANDY)) {
      return;
    }

	if (random.nextFloat() < SakuraConfig.pepper_weight / 4000.0F) {
      int posX = x  + world.rand.nextInt(16) + 8;
      int posZ = z  + world.rand.nextInt(16) + 8;
      BlockPos newPos = WorldUtil.findGround(world, new BlockPos(posX, 0, posZ), true, true, true);
      if ((newPos != null) && (BlockLoader.PEPPER_SPLINT.canPlaceBlockAt(world, newPos))) {
        world.setBlockState(newPos, BlockLoader.PEPPERCROP.getDefaultState(), 2);
      }
    }
}
 
Example #3
Source File: WorldGenBambooShot.java    From Sakura_mod with MIT License 6 votes vote down vote up
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator,IChunkProvider chunkProvider) {
    int x = chunkX * 16;
    int z = chunkZ * 16;
    
    Biome biome = world.getBiomeForCoordsBody(new BlockPos(x, 0, z));
    if (BiomeDictionary.hasType(biome, BiomeDictionary.Type.DEAD)
    		||BiomeDictionary.hasType(biome, BiomeDictionary.Type.SANDY)) {
      return;
    }
    
       if (random.nextFloat() < SakuraConfig.bambooshot_weight / 4000.0F)
    {
      int posX = x+ world.rand.nextInt(16) + 8;
      int posZ = z+ world.rand.nextInt(16) + 8;
      BlockPos newPos = WorldUtil.findGround(world, new BlockPos(posX, 0, posZ), true, true, true);
      if ((newPos != null) && (BlockLoader.BAMBOOSHOOT.canBlockStay(world, newPos))) {
        world.setBlockState(newPos, BlockLoader.BAMBOOSHOOT.getDefaultState(), 2);
      }
    }
}
 
Example #4
Source File: WorldGenVanilla.java    From Sakura_mod with MIT License 6 votes vote down vote up
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator,IChunkProvider chunkProvider) {
    int x = chunkX * 16;
    int z = chunkZ * 16;
    
    Biome biome = world.getBiomeForCoordsBody(new BlockPos(x, 0, z));
    if (BiomeDictionary.hasType(biome, BiomeDictionary.Type.DEAD)
    		||BiomeDictionary.hasType(biome, BiomeDictionary.Type.SANDY)) {
      return;
    }

	if (random.nextFloat() < SakuraConfig.vanilla_weight / 4000.0F)
    {
      int posX = x + world.rand.nextInt(16) + 8;
      int posZ = z + world.rand.nextInt(16) + 8;
      BlockPos newPos = WorldUtil.findGround(world, new BlockPos(posX, 0, posZ), true, true, true);
      if ((newPos != null) && (BlockLoader.VANILLA_SPLINT.canPlaceBlockAt(world, newPos))) {
        world.setBlockState(newPos, BlockLoader.VANILLACROP.getDefaultState(), 2);
      }
    }
}
 
Example #5
Source File: MultiblockControllerBase.java    From BeefCore with MIT License 6 votes vote down vote up
private void selectNewReferenceCoord() {
	IChunkProvider chunkProvider = worldObj.getChunkProvider();
	TileEntity theChosenOne = null;
	referenceCoord = null;

	for(IMultiblockPart part : connectedParts) {
		if(part.isInvalid() || !chunkProvider.chunkExists(part.xCoord >> 4, part.zCoord >> 4)) {
			// Chunk is unloading, skip this coord to prevent chunk thrashing
			continue;
		}

		if(referenceCoord == null || referenceCoord.compareTo(part.xCoord, part.yCoord, part.zCoord) > 0) {
			referenceCoord = part.getWorldLocation();
			theChosenOne = part;
		}
	}

	if(theChosenOne != null) {
		((IMultiblockPart)theChosenOne).becomeMultiblockSaveDelegate();
	}
}
 
Example #6
Source File: WorldGenManagerForIntraportals.java    From CommunityMod with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator,
		IChunkProvider chunkProvider)
{
	int x = random.nextInt(16) + 16*chunkX;
	int z = random.nextInt(16) + 16*chunkZ;
	int y = random.nextInt(world.getActualHeight()-10) + 5;
	BlockPos checkPos = new BlockPos(x,y,z);
	if (random.nextInt(100) == 0
			&& world.getBlockState(checkPos).getBlock() == Blocks.AIR
			&& world.getBlockState(checkPos.up()).getBlock() == Blocks.AIR
			&& world.getBlockState(checkPos.down()).getBlock() == Blocks.AIR)
	{
		world.setBlockState(checkPos, SubmodIntradimensionalPortals.intradimensional_portal_base.getDefaultState());
		//world.setBlockState(checkPos.up(), SubmodIntradimensionalPortals.intradimensional_portal_glowy_air.getDefaultState());
		//world.setBlockState(checkPos.down(), SubmodIntradimensionalPortals.intradimensional_portal_glowy_air.getDefaultState());
	}
}
 
Example #7
Source File: WorldGeneratorPneumaticCraft.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider){
    if(!(chunkGenerator instanceof ChunkProviderFlat)) { //don't generate on flatworlds
        switch(world.provider.dimensionId){
            case 0:
                generateSurface(world, random, chunkX * 16, chunkZ * 16);
                break;
            case -1:
                generateNether(world, random, chunkX * 16, chunkZ * 16);
                break;
            case 1:
                generateEnd(world, random, chunkX * 16, chunkZ * 16);
                break;
            default:
                generateSurface(world, random, chunkX * 16, chunkZ * 16);
        }
    }
}
 
Example #8
Source File: WorldGenAbandonedBase.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
    if (ConfigHolder.abandonedBaseRarity == 0 ||
        world.getWorldType() == WorldType.FLAT ||
        world.provider.getDimensionType() != DimensionType.OVERWORLD ||
        !world.getWorldInfo().isMapFeaturesEnabled()) {
        return; //do not generate in flat worlds, or in non-surface worlds
    }
    BlockPos randomPos = new BlockPos(chunkX * 16 + 8, 0, chunkZ * 16 + 8);

    if (random.nextInt(ConfigHolder.abandonedBaseRarity) == 0) {
        int variantNumber = random.nextInt(3);
        Rotation rotation = Rotation.values()[random.nextInt(Rotation.values().length)];
        ResourceLocation templateId = new ResourceLocation(GTValues.MODID, "abandoned_base/abandoned_base_1_" + variantNumber);
        Template template = TemplateManager.getBuiltinTemplate(world, templateId);
        BlockPos originPos = template.getZeroPositionWithTransform(randomPos, Mirror.NONE, rotation);
        originPos = TemplateManager.calculateAverageGroundLevel(world, originPos, template.getSize());
        template.addBlocksToWorld(world, originPos, new PlacementSettings().setRotation(rotation));
    }
}
 
Example #9
Source File: WorldGenCandelilla.java    From GardenCollection with MIT License 6 votes vote down vote up
@Override
public void generate (Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
    int x = chunkX * 16;
    int z = chunkZ * 16;

    BiomeGenBase biome = world.getWorldChunkManager().getBiomeGenAt(x, z);
    if (BiomeDictionary.isBiomeOfType(biome, BiomeDictionary.Type.COLD)
        || BiomeDictionary.isBiomeOfType(biome, BiomeDictionary.Type.NETHER)
        || BiomeDictionary.isBiomeOfType(biome, BiomeDictionary.Type.WET)
        || BiomeDictionary.isBiomeOfType(biome, BiomeDictionary.Type.WASTELAND)
        || BiomeDictionary.isBiomeOfType(biome, BiomeDictionary.Type.SNOWY))
        return;

    if (!BiomeDictionary.isBiomeOfType(biome, BiomeDictionary.Type.SANDY))
        return;

    if (random.nextInt(10) > 0)
        return;

    generate(world, random, x, world.getActualHeight() - 1, z);
}
 
Example #10
Source File: MoCChunkProviderWyvernLair.java    From mocreaturesdev with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Populates chunk with ores etc etc
 */
public void populate_old(IChunkProvider par1IChunkProvider, int par2, int par3)
{
    BlockSand.fallInstantly = true;

    MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Pre(par1IChunkProvider, worldObj, worldObj.rand, par2, par3, false));

    int var4 = par2 * 16;
    int var5 = par3 * 16;
    BiomeGenBase var6 = this.worldObj.getBiomeGenForCoords(var4 + 16, var5 + 16);
    var6.decorate(this.worldObj, this.worldObj.rand, var4, var5);

    MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Post(par1IChunkProvider, worldObj, worldObj.rand, par2, par3, false));

    BlockSand.fallInstantly = false;
}
 
Example #11
Source File: WorldGeneratorFlag.java    From AdvancedMod with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider){
    int x = chunkX * 16;
    int z = chunkZ * 16;
    switch(world.provider.dimensionId){
        case 0:
            generateSurface(world, x, z, random);
            break;
        case -1:
            generateNether(world, x, z, random);
            break;
        case 1:
            generateEnd(world, x, z, random);
            break;
        default:
            generateSurface(world, x, z, random);
    }
}
 
Example #12
Source File: CustomizableOreGen.java    From AdvancedRocketry with MIT License 6 votes vote down vote up
@Override
public void generate(Random random, int chunkX, int chunkZ, World world,
		IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {

	Predicate<IBlockState> predicate = null;
	if(DimensionManager.getInstance().isDimensionCreated(world.provider.getDimension()))
	{
		IBlockState state = ((DimensionProperties)DimensionManager.getInstance().getDimensionProperties(world.provider.getDimension())).getStoneBlock();
		if(state != null)
			predicate = new CustomPredicate(state);
	}
	
	for(int i = 0; i < numPerChunk; i++) {
		int coordX = 16*chunkX + random.nextInt(16);
		int coordY = heightLevel + random.nextInt(difference);
		int coordZ = 16*chunkZ + random.nextInt(16);

		if(predicate != null)
			new WorldGenMinable(oreToGen, clumpSize, predicate).generate(world, random, new BlockPos(coordX, coordY, coordZ));
		else
			new WorldGenMinable(oreToGen, clumpSize).generate(world, random, new BlockPos(coordX, coordY, coordZ));
	}

}
 
Example #13
Source File: WorldGeneratorSignals.java    From Signals with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider){
    // TODO when adding worldgen, resolve the note at https://github.com/MineMaarten/Signals/pull/80 regarding the possibility of rails not being included in the network.
    if(chunkX == 0) {
        int x = chunkX * 16 + 8;
        int y = 4;
        int startZ = chunkZ * 16;
        for(int z = startZ; z < startZ + 16; z++) {
            world.setBlockState(new BlockPos(x, y, z), Blocks.STONE.getDefaultState(), 0);
            world.setBlockState(new BlockPos(x, y + 1, z), Blocks.RAIL.getDefaultState().withProperty(BlockRail.SHAPE, EnumRailDirection.NORTH_SOUTH), 0);
            if(z % 256 == 0) {
                world.setBlockState(new BlockPos(x + 1, y + 1, z), ModBlocks.BLOCK_SIGNAL.getDefaultState().withProperty(BlockSignalBase.FACING, EnumFacing.NORTH), 0);

            }
        }
    }
}
 
Example #14
Source File: WorldGenPlacer.java    From ToroQuest with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
	if (random.nextInt(ToroQuestConfiguration.structureSpawnChance) != 0 || world.provider.getDimension() != 0) {
		return;
	}

	int roll = random.nextInt(5);

	switch (roll) {
	case 0:
		genMonolith(world, random, chunkX, chunkZ);
		break;
	case 1:
		genBastionsLair(world, random, chunkX, chunkZ);
		break;
	case 2:
		genMageTower(world, random, chunkX, chunkZ);
		break;
	case 3:
		genThroneRoom(world, random, chunkX, chunkZ);
		break;
	case 4:
		genGraveyard(world, random, chunkX, chunkZ);
		break;
	}
}
 
Example #15
Source File: SoyGenerator.java    From TofuCraftReload with MIT License 6 votes vote down vote up
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
    int x = chunkX * 16;
    int z = chunkZ * 16;

    Biome biome = world.getBiomeForCoordsBody(new BlockPos(x, 0, z));
    if (BiomeDictionary.hasType(biome, BiomeDictionary.Type.DEAD)
            || BiomeDictionary.hasType(biome, BiomeDictionary.Type.SANDY)) {
        return;
    }

    if (random.nextFloat() < 70 / 4000.0F) {
        int posX = x + world.rand.nextInt(16) + 8;
        int posZ = z + world.rand.nextInt(16) + 8;
        BlockPos newPos = WorldUtil.findGround(world, new BlockPos(posX, 0, posZ), true, true, true);
        if ((newPos != null) && (BlockLoader.SOYBEAN.canPlaceBlockAt(world, newPos))) {
            world.setBlockState(newPos, BlockLoader.SOYBEAN.getDefaultState().withProperty(BlockSoybean.AGE, random.nextInt(4)), 2);
        }
    }
}
 
Example #16
Source File: TestGenerator.java    From simpleretrogen with GNU General Public License v3.0 5 votes vote down vote up
@Mod.EventHandler
public void preinit(FMLPreInitializationEvent init)
{
    final Logger modLog = init.getModLog();
    IWorldGenerator gen = new IWorldGenerator() {
        @Override
        public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider)
        {
            modLog.log(Level.INFO, "Calling!");
        }
    };
    GameRegistry.registerWorldGenerator(gen, 10);
}
 
Example #17
Source File: OreGenerator.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
public void generate(Random random, int chunkX, int chunkZ, World world,
		IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
	
	OreGenEvent event = new OreGenEvent.GenerateMinable(world, random, this, new BlockPos(chunkX,0,chunkZ), EventType.CUSTOM);
	MinecraftForge.ORE_GEN_BUS.post(event);
	if(event.getResult() != Result.DENY) {
		if(Configuration.generateCopper) {
			generate(world, MaterialRegistry.getMaterialFromName("Copper"), Configuration.copperPerChunk, Configuration.copperClumpSize, chunkX, chunkZ, random);
		}

		if(Configuration.generateTin) {
			generate(world, MaterialRegistry.getMaterialFromName("Tin"), Configuration.tinPerChunk, Configuration.tinClumpSize, chunkX, chunkZ, random);
		}
		if(Configuration.generateRutile) {
			generate(world, MaterialRegistry.getMaterialFromName("Rutile"), Configuration.rutilePerChunk, Configuration.rutileClumpSize, chunkX, chunkZ, random);
		}
		if(Configuration.generateAluminum) {
			generate(world, MaterialRegistry.getMaterialFromName("Aluminum"), Configuration.aluminumPerChunk, Configuration.aluminumClumpSize, chunkX, chunkZ, random);
		}
		if(Configuration.generateIridium) {
			generate(world, MaterialRegistry.getMaterialFromName("Iridium"), Configuration.IridiumPerChunk, Configuration.IridiumClumpSize, chunkX, chunkZ, random);
		}

		if(Configuration.generateDilithium) {
			int dilithiumChance = Configuration.dilithiumPerChunk;
			if(world.provider instanceof WorldProviderPlanet) {
				dilithiumChance = DimensionProperties.AtmosphereTypes.getAtmosphereTypeFromValue(DimensionManager.getInstance().getDimensionProperties(world.provider.getDimension()).getAtmosphereDensity()) == DimensionProperties.AtmosphereTypes.NONE ? Configuration.dilithiumPerChunkMoon : Configuration.dilithiumPerChunk;;
			}
			
			for(int i = 0; i < dilithiumChance; i++) {
				int coordX = 16*chunkX + random.nextInt(16);
				int coordY = random.nextInt(64);
				int coordZ = 16*chunkZ + random.nextInt(16);

				new WorldGenMinable(MaterialRegistry.getMaterialFromName("Dilithium").getBlock().getDefaultState(), Configuration.dilithiumClumpSize).generate(world, random, new BlockPos(coordX, coordY, coordZ));
			}
		}
	}
}
 
Example #18
Source File: BRSimpleOreGenerator.java    From BigReactors with MIT License 5 votes vote down vote up
/**
 * Call to discover if this generator WISHES to generate in this world.
 * @param world
 * @return
 */
public boolean shouldGenerateInWorld(World world) {
	IChunkProvider chunkProvider = world.getChunkProvider();
	if(dimensionBlacklist.contains(world.provider.dimensionId)) {
		return false;
	}
	else if(chunkProvider instanceof ChunkProviderHell) {
		return false;
	}
	else if(chunkProvider instanceof ChunkProviderEnd) {
		return false;
	}

	return true;
}
 
Example #19
Source File: WorldRetrogen.java    From simpleretrogen with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider)
{
    FMLLog.fine("Passing generation for %s through to underlying generator", tag);
    delegate.generate(random, chunkX, chunkZ, world, chunkGenerator, chunkProvider);
    ChunkPos chunkCoordIntPair = new ChunkPos(chunkX, chunkZ);
    completeRetrogen(chunkCoordIntPair, world, tag);
}
 
Example #20
Source File: WorldGenTFC.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGen,IChunkProvider chunkProvider)
{
	chunk = world.getChunkFromChunkCoords(chunkX, chunkZ);
	chunkX *= 16;
	chunkZ *= 16;

	map = Core.getMapForWorld(world, new BlockPos(chunkX, 0, chunkZ));
	iMoisture = map.getParams().getIslandMoisture();
}
 
Example #21
Source File: MultiblockControllerBase.java    From BeefCore with MIT License 5 votes vote down vote up
/**
 * Detach all parts. Return a set of all parts which still
 * have a valid tile entity. Chunk-safe.
 * @return A set of all parts which still have a valid tile entity.
 */
public Set<IMultiblockPart> detachAllBlocks() {
	if(worldObj == null) { return new HashSet<IMultiblockPart>(); }
	
	IChunkProvider chunkProvider = worldObj.getChunkProvider();
	for(IMultiblockPart part : connectedParts) {
		if(chunkProvider.chunkExists(part.xCoord >> 4, part.zCoord >> 4)) {
			onDetachBlock(part);
		}
	}

	Set<IMultiblockPart> detachedParts = connectedParts;
	connectedParts = new HashSet<IMultiblockPart>();
	return detachedParts;
}
 
Example #22
Source File: HGWorldGen.java    From HexxitGear with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {

    if (HexxitGear.getDimBlacklist().contains(world.provider.dimensionId))
        return;

    if (world.getWorldInfo().getTerrainType().getWorldTypeName().equals("flat"))
        return;

    int xMin = chunkX << 4;
    int zMin = chunkZ << 4;

    int startX = xMin + random.nextInt(16);
    int startZ = zMin + random.nextInt(16);

    int tries = random.nextInt(2);

    for (int i=0; i < tries; i++) {
        int x = startX + random.nextInt(8) - random.nextInt(8);
        int z = startZ + random.nextInt(8) - random.nextInt(8);
        int y = world.getHeightValue(x, z);

        if ((world.isAirBlock(x, y, z) || (world.getBlockId(x,y,z) == Block.snow.blockID)) && HexxitGear.hexbiscus.canBlockStay(world, x, y, z)) {
            if (random.nextInt(50) > 1)
                continue;

            world.setBlock(x, y, z, HexxitGear.hexbiscus.blockID, 0, 0);
        }
    }
}
 
Example #23
Source File: Core.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
public static boolean areChunksLoadedInArea(IChunkProvider provider, ChunkPos min, ChunkPos max)
{
	for(int x = min.chunkXPos; x <= max.chunkXPos; x++)
	{
		for(int z = min.chunkZPos; z <= max.chunkZPos; z++)
		{
			if(provider.getLoadedChunk(x, z) == null)
				return false;
		}
	}
	return true;
}
 
Example #24
Source File: QuantumOreGenerator.java    From qcraft-mod with Apache License 2.0 5 votes vote down vote up
@Override
public void generate( Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider )
{
    if( !world.provider.isHellWorld && world.provider.terrainType != WorldType.FLAT )
    {
        generateSurface( world, random, chunkX * 16, chunkZ * 16 );
    }
}
 
Example #25
Source File: ChunkProviderTCOuter.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void populate(IChunkProvider p_73153_1_, int p_73153_2_, int p_73153_3_) {
    net.minecraft.block.BlockFalling.fallInstantly = true;
    MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Pre(p_73153_1_, this.worldObj, this.worldObj.rand, p_73153_2_, p_73153_3_, false));

    int k = p_73153_2_ * 16;
    int l = p_73153_3_ * 16;
    BiomeGenBase biomegenbase = this.worldObj.getBiomeGenForCoords(k + 16, l + 16);
    biomegenbase.decorate(this.worldObj, this.worldObj.rand, k, l);

    MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Post(p_73153_1_, this.worldObj, this.worldObj.rand, p_73153_2_, p_73153_3_, false));
    net.minecraft.block.BlockFalling.fallInstantly = false;
}
 
Example #26
Source File: ForgeQueue_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean regenerateChunk(World world, int x, int z, BaseBiome biome, Long seed) {
    IChunkProvider provider = world.getChunkProvider();
    if (!(provider instanceof ChunkProviderServer)) {
        return false;
    }
    ChunkProviderServer chunkServer = (ChunkProviderServer) provider;
    IChunkProvider chunkProvider = chunkServer.serverChunkGenerator;

    long pos = ChunkCoordIntPair.chunkXZ2Int(x, z);
    Chunk mcChunk;
    if (chunkServer.chunkExists(x, z)) {
        mcChunk = chunkServer.loadChunk(x, z);
        mcChunk.onChunkUnload();
    }
    try {
        Field droppedChunksSetField = chunkServer.getClass().getDeclaredField("field_73248_b");
        droppedChunksSetField.setAccessible(true);
        Set droppedChunksSet = (Set) droppedChunksSetField.get(chunkServer);
        droppedChunksSet.remove(pos);
    } catch (Throwable e) {
        MainUtil.handleError(e);
    }
    chunkServer.id2ChunkMap.remove(pos);
    mcChunk = chunkProvider.provideChunk(x, z);
    chunkServer.id2ChunkMap.add(pos, mcChunk);
    chunkServer.loadedChunks.add(mcChunk);
    if (mcChunk != null) {
        mcChunk.onChunkLoad();
        mcChunk.populateChunk(chunkProvider, chunkProvider, x, z);
    }
    return true;
}
 
Example #27
Source File: TofuOreGenerator.java    From TofuCraftReload with MIT License 5 votes vote down vote up
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
    if (world.provider instanceof WorldProviderSurface) {
        this.generateOre(world, random, chunkX << 4, chunkZ << 4);

    }
}
 
Example #28
Source File: MultiblockTileEntityBase.java    From BeefCore with MIT License 5 votes vote down vote up
@Override
public IMultiblockPart[] getNeighboringParts() {
	CoordTriplet[] neighbors = new CoordTriplet[] {
			new CoordTriplet(this.xCoord-1, this.yCoord, this.zCoord),
			new CoordTriplet(this.xCoord, this.yCoord-1, this.zCoord),
			new CoordTriplet(this.xCoord, this.yCoord, this.zCoord-1),
			new CoordTriplet(this.xCoord, this.yCoord, this.zCoord+1),
			new CoordTriplet(this.xCoord, this.yCoord+1, this.zCoord),
			new CoordTriplet(this.xCoord+1, this.yCoord, this.zCoord)
	};

	TileEntity te;
	List<IMultiblockPart> neighborParts = new ArrayList<IMultiblockPart>();
	IChunkProvider chunkProvider = worldObj.getChunkProvider();
	for(CoordTriplet neighbor : neighbors) {
		if(!chunkProvider.chunkExists(neighbor.getChunkX(), neighbor.getChunkZ())) {
			// Chunk not loaded, skip it.
			continue;
		}

		te = this.worldObj.getTileEntity(neighbor.x, neighbor.y, neighbor.z);
		if(te instanceof IMultiblockPart) {
			neighborParts.add((IMultiblockPart)te);
		}
	}
	IMultiblockPart[] tmp = new IMultiblockPart[neighborParts.size()];
	return neighborParts.toArray(tmp);
}
 
Example #29
Source File: ClientStateMachine.java    From malmo with MIT License 5 votes vote down vote up
private boolean isChunkReady()
{
    // First, find the starting position we ought to have:
    List<AgentSection> agents = currentMissionInit().getMission().getAgentSection();
    if (agents == null || agents.size() <= currentMissionInit().getClientRole())
        return true;    // This should never happen.
    AgentSection as = agents.get(currentMissionInit().getClientRole());
    if (as.getAgentStart() != null && as.getAgentStart().getPlacement() != null)
    {
        PosAndDirection pos = as.getAgentStart().getPlacement();
        int x = MathHelper.floor(pos.getX().doubleValue()) >> 4;
        int z = MathHelper.floor(pos.getZ().doubleValue()) >> 4;
        // Now get the chunk we should be starting in:
        IChunkProvider chunkprov = Minecraft.getMinecraft().world.getChunkProvider();
        EntityPlayerSP player = Minecraft.getMinecraft().player;
        if (player.addedToChunk)
        {
            // Our player is already added to a chunk - is it the right one?
            Chunk actualChunk = chunkprov.provideChunk(player.chunkCoordX, player.chunkCoordZ);
            Chunk requestedChunk = chunkprov.provideChunk(x,  z);
            if (actualChunk == requestedChunk && actualChunk != null && !actualChunk.isEmpty())
            {
                // We're in the right chunk, and it's not an empty chunk.
                // We're ready to proceed, but first set our client positions to where we ought to be.
                // The server should be doing this too, but there's no harm (probably) in doing it ourselves.
                player.posX = pos.getX().doubleValue();
                player.posY = pos.getY().doubleValue();
                player.posZ = pos.getZ().doubleValue();
                return true;
            }
        }
        return false;   // Our starting position has been specified, but it's not yet ready.
    }
    return true;    // No starting position specified, so doesn't matter where we start.
}
 
Example #30
Source File: WorldDummy.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
protected IChunkProvider createChunkProvider() {
	if(this.isRemote)
		return new ChunkProviderClient(this);
	else 
		return null;
}