Java Code Examples for net.minecraft.world.chunk.IChunkProvider

The following examples show how to use net.minecraft.world.chunk.IChunkProvider. These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: TofuCraftReload   Source File: SoyGenerator.java    License: 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 2
Source Project: Sakura_mod   Source File: WorldGenBambooShot.java    License: 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 3
Source Project: Sakura_mod   Source File: WorldGenPepper.java    License: 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 4
Source Project: Sakura_mod   Source File: WorldGenVanilla.java    License: 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
@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 6
@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 7
Source Project: ToroQuest   Source File: WorldGenPlacer.java    License: 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 8
Source Project: Valkyrien-Skies   Source File: ValkyrienSkiesWorldGen.java    License: 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 9
@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 10
Source Project: AdvancedRocketry   Source File: CustomizableOreGen.java    License: 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 11
@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 Project: GardenCollection   Source File: WorldGenCandelilla.java    License: 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 13
/**
 * 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 14
@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 15
Source Project: BeefCore   Source File: MultiblockControllerBase.java    License: 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 16
Source Project: TofuCraftReload   Source File: TofuOreGenerator.java    License: 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 17
Source Project: Sakura_mod   Source File: WorldGenIronSand.java    License: MIT License 5 votes vote down vote up
@Override
	public void generate(Random rand, int chunkX, int chunkZ, World worldIn, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
		  for (int i = 0; i < block_count; i++) {
	            int rX = (chunkX  * 16) + rand.nextInt(16) + 8;
	            int rY = 48 + rand.nextInt(19);
	            int rZ = (chunkZ  * 16) + rand.nextInt(16) + 8;
	            BlockPos pos = new BlockPos(rX, rY, rZ);
	            IBlockState stateAt = worldIn.getBlockState(pos);
	            if(!stateAt.getBlock().equals(Blocks.SAND)) {
	                continue;
	            }

	            boolean canSpawn = false;
	            for (int yy = 0; yy < 2; yy++) {
	                BlockPos check = pos.offset(EnumFacing.UP, yy);
	                IBlockState bs = worldIn.getBlockState(check);
	                Block block = bs.getBlock();
	                if(worldIn.getBiome(pos) instanceof BiomeBeach|| worldIn.getBiome(pos) instanceof BiomeRiver)
	                if((worldIn.isAirBlock(pos.up())||block instanceof BlockLiquid && bs.getMaterial() == Material.WATER)) {
	                    canSpawn = true;
	                    break;
	                }
	            }
	            if(!canSpawn)
	                continue;
	            worldIn.setBlockState(pos, BlockLoader.IRON_SAND.getDefaultState());
//	            SakuraMain.logger.info(String.format("Iron Sand in: %d %d %d", pos.getX(),pos.getY(),pos.getZ()));
	        }
	}
 
Example 18
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
    if (world.getWorldType() == WorldType.FLAT ||
        !world.provider.isSurfaceWorld()) {
        return; //do not generate in flat worlds, or in non-surface worlds
    }
    BlockPos randomPos = new BlockPos(chunkX * 16 + 8, 0, chunkZ * 16 + 8);
    Biome biome = world.getBiome(randomPos);

    if (BiomeDictionary.hasType(biome, Type.COLD) ||
        BiomeDictionary.hasType(biome, Type.HOT) ||
        BiomeDictionary.hasType(biome, Type.DRY) ||
        BiomeDictionary.hasType(biome, Type.DEAD) ||
        BiomeDictionary.hasType(biome, Type.SPOOKY))
        return; //do not generate in inappropriate biomes

    int rubberTreeChance = 6;
    if (BiomeDictionary.hasType(biome, Type.SWAMP) ||
        BiomeDictionary.hasType(biome, Type.WET))
        rubberTreeChance /= 2; //double chance of spawning in swamp or wet biomes

    if (random.nextInt(rubberTreeChance) == 0) {
        randomPos = world.getTopSolidOrLiquidBlock(randomPos).down();
        IBlockState solidBlockState = world.getBlockState(randomPos);
        BlockGregSapling sapling = MetaBlocks.SAPLING;
        if (solidBlockState.getBlock().canSustainPlant(solidBlockState, world, randomPos, EnumFacing.UP, sapling)) {
            BlockPos abovePos = randomPos.up();
            IBlockState saplingState = sapling.getDefaultState()
                .withProperty(BlockGregSapling.VARIANT, LogVariant.RUBBER_WOOD);
            world.setBlockState(abovePos, saplingState);
            sapling.generateTree(world, abovePos, saplingState, random);
        }
    }
}
 
Example 19
Source Project: bartworks   Source File: ChunkProviderRoss128ba.java    License: MIT License 5 votes vote down vote up
@Override
public void populate(IChunkProvider par1IChunkProvider, int par2, int par3) {
    super.populate(par1IChunkProvider, par2, par3);
    BlockFalling.fallInstantly = true;
    ChunkProviderRoss128b.BWOreGen.generate(this.rand, par2, par3, this.worldObj, this, this);
    BlockFalling.fallInstantly = false;
}
 
Example 20
Source Project: bartworks   Source File: BW_WordGenerator.java    License: MIT License 5 votes vote down vote up
public WorldGenContainer(int aX, int aZ, int aDimensionType, World aWorld, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) {
    this.mX = aX;
    this.mZ = aZ;
    this.mDimensionType = aDimensionType;
    this.mWorld = aWorld;
    this.mChunkGenerator = aChunkGenerator;
    this.mChunkProvider = aChunkProvider;
}
 
Example 21
Source Project: GT-Classic   Source File: GTWorldGen.java    License: GNU Lesser 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) {
	Biome biomegenbase = world.getBiome(new BlockPos(chunkX * 16 + 16, 128, chunkZ * 16 + 16));
	// Any Biome
	GTOreGenerator.generateBasicVein(GTBlocks.oreIridium, GTConfig.generation.iridiumGenerate, GTConfig.generation.iridiumSize, GTConfig.generation.iridiumWeight, 0, 128, Blocks.STONE, world, random, chunkX, chunkZ);
	// Jungle Biomes
	if (BiomeDictionary.hasType(biomegenbase, Type.JUNGLE)) {
		GTOreGenerator.generateBasicVein(GTBlocks.oreSheldonite, GTConfig.generation.sheldoniteGenerate, GTConfig.generation.sheldoniteSize, GTConfig.generation.sheldoniteWeight, 10, 30, Blocks.STONE, world, random, chunkX, chunkZ);
	}
	// Hot Biomes
	if (BiomeDictionary.hasType(biomegenbase, Type.HOT)) {
		GTOreGenerator.generateBasicVein(GTBlocks.oreRuby, GTConfig.generation.rubyGenerate, GTConfig.generation.rubySize, GTConfig.generation.rubyWeight, 0, 48, Blocks.STONE, world, random, chunkX, chunkZ);
	}
	// Ocean Biomes
	if (BiomeDictionary.hasType(biomegenbase, Type.OCEAN) || BiomeDictionary.hasType(biomegenbase, Type.BEACH)) {
		GTOreGenerator.generateBasicVein(GTBlocks.oreSapphire, GTConfig.generation.sapphireGenerate, GTConfig.generation.sapphireSize, GTConfig.generation.sapphireWeight, 0, 48, Blocks.STONE, world, random, chunkX, chunkZ);
	}
	// Forest or Plains Biomes
	if (BiomeDictionary.hasType(biomegenbase, Type.FOREST)
			|| (BiomeDictionary.hasType(biomegenbase, Type.PLAINS))) {
		GTOreGenerator.generateBasicVein(GTBlocks.oreBauxite, GTConfig.generation.bauxiteGenerate, GTConfig.generation.bauxiteSize, GTConfig.generation.bauxiteWeight, 50, 120, Blocks.STONE, world, random, chunkX, chunkZ);
	}
	if (world.provider.getDimensionType().equals(DimensionType.OVERWORLD)) {
		for (Block block : GTBedrockOreHandler.getBedrockOreMap().keySet()) {
			if (GTBedrockOreHandler.shouldGTCHandleGeneration(block)) {
				GTOreGenerator.generateBedrockVein(block, world, random, chunkX, chunkZ);
			}
		}
	}
}
 
Example 22
Source Project: ehacks-pro   Source File: Debug.java    License: GNU General Public License v3.0 5 votes vote down vote up
public static List<TileEntity> getNearTileEntities() {
    ArrayList<TileEntity> out = new ArrayList<>();
    IChunkProvider chunkProvider = getWorld().getChunkProvider();
    if (chunkProvider instanceof ChunkProviderClient) {
        List<Chunk> chunks = ReflectionHelper.getPrivateValue(ChunkProviderClient.class, (ChunkProviderClient) chunkProvider, Mappings.chunkListing);
        chunks.forEach((chunk) -> {
            chunk.chunkTileEntityMap.values().stream().filter((entityObj) -> !(!(entityObj instanceof TileEntity))).forEachOrdered((entityObj) -> {
                out.add((TileEntity) entityObj);
            });
        });
    }
    return out;
}
 
Example 23
Source Project: ehacks-pro   Source File: NoLimitClear.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onModuleEnabled() {
    try {
        Class.forName("powercrystals.minefactoryreloaded.net.ServerPacketHandler");
        int count = 0;
        IChunkProvider chunkProvider = Wrapper.INSTANCE.world().getChunkProvider();
        if (chunkProvider instanceof ChunkProviderClient) {
            ChunkProviderClient clientProvider = (ChunkProviderClient) chunkProvider;
            List<Chunk> chunks = ReflectionHelper.getPrivateValue(ChunkProviderClient.class, clientProvider, Mappings.chunkListing);
            for (Chunk chunk : chunks) {
                for (Object entityObj : chunk.chunkTileEntityMap.values()) {
                    if (!(entityObj instanceof TileEntity)) {
                        return;
                    }
                    TileEntity entity = (TileEntity) entityObj;
                    if (entity instanceof IInventory) {
                        IInventory inv = (IInventory) entity;
                        TileEntity ent = entity;
                        for (int i = 0; i < inv.getSizeInventory(); i++) {
                            setSlot(i, ent.xCoord, ent.yCoord, ent.zCoord);
                        }
                        count++;
                    }
                }
            }
        }
        InteropUtils.log("Cleared " + String.valueOf(count) + " containers", this);
        this.off();
    } catch (Exception ex) {
        this.off();
    }
}
 
Example 24
@Override
protected IChunkProvider createChunkProvider()
{
    ChunkProviderSchematic provider = new ChunkProviderSchematic(this);

    ((IMixinWorldClient) (Object) this).setClientChunkProvider(provider);

    return provider;
}
 
Example 25
Source Project: customstuff4   Source File: WorldGenOre.java    License: 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)
{
    if (world.provider.getDimension() != dimension)
    {
        return;
    }

    BlockPos chunkPos = new BlockPos(chunkX * 16, 0, chunkZ * 16);

    if (maxHeight < minHeight)
    {
        int i = minHeight;
        minHeight = maxHeight;
        maxHeight = i;
    } else if (maxHeight == minHeight)
    {
        if (minHeight < 255)
        {
            ++maxHeight;
        } else
        {
            --minHeight;
        }
    }

    for (int j = 0; j < count; ++j)
    {
        BlockPos blockpos = chunkPos.add(random.nextInt(16), random.nextInt(maxHeight - minHeight) + minHeight, random.nextInt(16));
        gen.generate(world, random, blockpos);
    }
}
 
Example 26
Source Project: Valkyrien-Skies   Source File: MixinChunk.java    License: Apache License 2.0 5 votes vote down vote up
@Inject(method = "populate(Lnet/minecraft/world/chunk/IChunkProvider;Lnet/minecraft/world/gen/IChunkGenerator;)V", at = @At("HEAD"), cancellable = true)
public void prePopulateChunk(IChunkProvider provider, IChunkGenerator generator,
    CallbackInfo callbackInfo) {
    if (PhysicsChunkManager.isLikelyShipChunk(this.x, this.z)) {
        callbackInfo.cancel();
    }
}
 
Example 27
Source Project: malmo   Source File: ClientStateMachine.java    License: 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 28
@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 29
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 30
Source Project: qcraft-mod   Source File: QuantumOreGenerator.java    License: 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 );
    }
}