下面列出了怎么用net.minecraft.world.chunk.IChunkProvider的API类实例代码及写法,或者点击链接到github查看源代码。
@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);
}
}
}
@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);
}
}
}
@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);
}
}
}
@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);
}
}
}
@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());
}
}
@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));
}
}
@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;
}
}
@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;
}
}
}
@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);
}
}
}
}
@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));
}
}
@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);
}
}
@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);
}
/**
* 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;
}
@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);
}
}
}
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();
}
}
@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);
}
}
@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()));
}
}
@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);
}
}
}
@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;
}
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;
}
@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);
}
}
}
}
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;
}
@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();
}
}
@Override
protected IChunkProvider createChunkProvider()
{
ChunkProviderSchematic provider = new ChunkProviderSchematic(this);
((IMixinWorldClient) (Object) this).setClientChunkProvider(provider);
return provider;
}
@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);
}
}
@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();
}
}
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.
}
@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;
}
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;
}
@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 );
}
}