Java Code Examples for net.minecraft.world.chunk.Chunk#setChunkModified()

The following examples show how to use net.minecraft.world.chunk.Chunk#setChunkModified() . 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: SemiBlockManager.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
private void setSemiBlock(World world, int x, int y, int z, ISemiBlock semiBlock, Chunk chunk){
    if(semiBlock != null && !registeredTypes.containsValue(semiBlock.getClass())) throw new IllegalStateException("ISemiBlock \"" + semiBlock + "\" was not registered!");
    ChunkPosition pos = new ChunkPosition(x, y, z);
    if(semiBlock != null) {
        semiBlock.initialize(world, pos);
        addingBlocks.add(semiBlock);
    } else {
        ISemiBlock removedBlock = getOrCreateMap(chunk).get(pos);
        if(removedBlock != null) {
            removedBlock.invalidate();
            for(EntityPlayerMP player : syncList.get(chunk)) {
                NetworkHandler.sendTo(new PacketSetSemiBlock(pos, null), player);
            }
        }
    }
    chunk.setChunkModified();
}
 
Example 2
Source File: MultiblockControllerBase.java    From BeefCore with MIT License 5 votes vote down vote up
/**
 * Driver for the update loop. If the machine is assembled, runs
 * the game logic update method.
 * @see erogenousbeef.core.multiblock.MultiblockControllerBase#update() //TODO Fix this Javadoc
 */
public final void updateMultiblockEntity() {
	if(connectedParts.isEmpty()) {
		// This shouldn't happen, but just in case...
		MultiblockRegistry.addDeadController(this.worldObj, this);
		return;
	}

	if(this.assemblyState != AssemblyState.Assembled) {
		// Not assembled - don't run game logic
		return;
	}

	if(worldObj.isRemote) {
		updateClient();
	}
	else if(updateServer()) {
		// If this returns true, the server has changed its internal data. 
		// If our chunks are loaded (they should be), we must mark our chunks as dirty.
		if(minimumCoord != null && maximumCoord != null &&
				 this.worldObj.checkChunksExist(minimumCoord.x, minimumCoord.y, minimumCoord.z,
						 						maximumCoord.x, maximumCoord.y, maximumCoord.z)) {
			int minChunkX = minimumCoord.x >> 4;
			int minChunkZ = minimumCoord.z >> 4;
			int maxChunkX = maximumCoord.x >> 4;
			int maxChunkZ = maximumCoord.z >> 4;
			
			for(int x = minChunkX; x <= maxChunkX; x++) {
				for(int z = minChunkZ; z <= maxChunkZ; z++) {
					// Ensure that we save our data, even if the our save delegate is in has no TEs.
					Chunk chunkToSave = this.worldObj.getChunkFromChunkCoords(x, z);
					chunkToSave.setChunkModified();
				}
			}
		}
	}
	// Else: Server, but no need to save data.
}
 
Example 3
Source File: ForgeQueue_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void saveChunk(Chunk chunk) {
    chunk.setChunkModified();
}
 
Example 4
Source File: SpongeQueue_1_11.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void saveChunk(Chunk chunk) {
    chunk.setChunkModified();
}
 
Example 5
Source File: ForgeQueue_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void saveChunk(Chunk chunk) {
    chunk.setChunkModified();
}
 
Example 6
Source File: ForgeQueue_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void saveChunk(Chunk chunk) {
    chunk.setChunkModified();
}
 
Example 7
Source File: ForgeQueue_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void saveChunk(Chunk chunk) {
    chunk.setChunkModified();
}
 
Example 8
Source File: ForgeQueue_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void saveChunk(Chunk chunk) {
    chunk.setChunkModified();
}
 
Example 9
Source File: RegenChunkCommand.java    From TFC2 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] params)
{
	EntityPlayerMP player;
	try {
		player = getCommandSenderAsPlayer(sender);
	} catch (PlayerNotFoundException e) {
		return;
	}

	if(!player.isCreative())
		return;

	WorldServer world = server.worldServerForDimension(player.getEntityWorld().provider.getDimension());

	if(player.getEntityWorld().provider.getDimension() == 0 && params.length == 1)
	{
		int radius = Integer.parseInt(params[0]);

		for(int i = -radius; i <= radius; i++)
		{
			for(int k = -radius; k <= radius; k++)
			{
				int x = (((int)player.posX+i*16) >> 4);
				int z = (((int)player.posZ+k*16) >> 4);

				ChunkProviderServer cps = world.getChunkProvider();

				Chunk c = cps.chunkGenerator.provideChunk(x, z);
				Chunk old = world.getChunkProvider().provideChunk(x, z);
				old.setStorageArrays(c.getBlockStorageArray());
				c.setTerrainPopulated(false);
				c.onChunkLoad();
				c.setChunkModified();
				c.checkLight();
				cps.chunkGenerator.populate(c.xPosition, c.zPosition);
				net.minecraftforge.fml.common.registry.GameRegistry.generateWorld(c.xPosition, c.zPosition, world, cps.chunkGenerator, world.getChunkProvider());
				c.setChunkModified();
				player.connection.sendPacket(new SPacketChunkData(cps.provideChunk(x, z), 0xffffffff));
			}
		}

		/*for(int i = -radius; i <= radius; i++)
		{
			for(int k = -radius; k <= radius; k++)
			{
				int x = (((int)player.posX+i*16) >> 4);
				int z = (((int)player.posZ+k*16) >> 4);

				ChunkProviderServer cps = world.getChunkProvider();

				Chunk c = cps.chunkGenerator.provideChunk(x, z);
				Chunk old = world.getChunkProvider().provideChunk(x, z);
				old.populateChunk(cps, cps.chunkGenerator);

				if (c.isTerrainPopulated())
				{
					if (cps.chunkGenerator.generateStructures(c, c.xPosition, c.zPosition))
					{
						c.setChunkModified();
					}
				}
				else
				{
					c.checkLight();
					cps.chunkGenerator.populate(c.xPosition, c.zPosition);
					net.minecraftforge.fml.common.registry.GameRegistry.generateWorld(c.xPosition, c.zPosition, world, cps.chunkGenerator, world.getChunkProvider());
					c.setChunkModified();
				}

				player.connection.sendPacket(new SPacketChunkData(cps.provideChunk(x, z), 0xffffffff));
			}
		}*/
	}
	else if(player.getEntityWorld().provider.getDimension() == 0 && params.length == 2 && params[1].equalsIgnoreCase("hex"))
	{
		execute(server, sender, new String[] {params[0]});
		IslandMap map = Core.getMapForWorld(world, player.getPosition());
		HexGenRegistry.generate(Core.getMapForWorld(world, player.getPosition()), map.getClosestCenter(player.getPosition()), world);
	}
}