Added /bop stripchunk for testing ore generation and other underground stuff

This commit is contained in:
Adubbz 2015-04-07 15:46:06 +10:00
parent a3bb33d3aa
commit 35864315b9
2 changed files with 86 additions and 2 deletions

View file

@ -10,15 +10,20 @@ package biomesoplenty.common.command;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.command.WrongUsageException;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
import net.minecraft.util.BlockPos;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
import biomesoplenty.common.util.biome.BiomeUtils;
import com.google.common.collect.Lists;
@ -64,6 +69,10 @@ public class BOPCommand extends CommandBase
{
teleportFoundBiome(sender, args);
}
else if ("stripchunk".equals(args[0]))
{
stripChunk(sender, args);
}
}
private void getBiomeName(ICommandSender sender, String[] args) throws CommandException
@ -107,12 +116,86 @@ public class BOPCommand extends CommandBase
}
}
private void stripChunk(ICommandSender sender, String[] args) throws CommandException
{
if (args.length < 5)
{
throw new WrongUsageException("commands.biomesoplenty.stripchunk.usage");
}
int radius = parseInt(args[1]);
String mode = args[2];
boolean blacklist;
if (mode.equals("include")) blacklist = false;
else if (mode.equals("exclude")) blacklist = true;
else
{
throw new WrongUsageException("commands.biomesoplenty.stripchunk.usage");
}
List<IBlockState> stateList = Lists.newArrayList();
for (int i = 0; i < (args.length - 3) / 2; i++)
{
Block block = getBlockByText(sender, args[i * 2 + 3]);
int metadata = parseInt(args[i * 2 + 3 + 1]);
stateList.add(block.getStateFromMeta(metadata));
}
BlockPos playerPos = sender.getPosition();
World world = sender.getEntityWorld();
int playerChunkX = playerPos.getX() >> 4;
int playerChunkZ = playerPos.getZ() >> 4;
for (int chunkX = -radius; chunkX < radius; chunkX++)
{
for (int chunkZ = -radius; chunkZ < radius; chunkZ++)
{
Chunk chunk = world.getChunkFromChunkCoords(playerChunkX + chunkX, (playerChunkZ + chunkZ));
for (ExtendedBlockStorage blockStorage : chunk.getBlockStorageArray())
{
if (blockStorage != null)
{
for (int x = 0; x < 16; x++)
{
for (int y = 0; y < 16; y++)
{
for (int z = 0; z < 16; z++)
{
BlockPos pos = new BlockPos(chunk.xPosition * 16 + x, blockStorage.getYLocation() + y, chunk.zPosition * 16 + z);
IBlockState state = blockStorage.get(x, y, z);
if (((!blacklist && stateList.contains(state)) || (blacklist && !stateList.contains(state))) && pos.getY() > 0)
{
blockStorage.set(x, y, z, Blocks.air.getDefaultState());
world.markBlockForUpdate(pos);
world.notifyNeighborsRespectDebug(pos, Blocks.air);
}
}
}
}
}
}
chunk.generateSkylightMap();
}
}
}
@Override
public List addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos)
{
if (args.length == 1)
{
return getListOfStringsMatchingLastWord(args, "biomename", "tpbiome");
return getListOfStringsMatchingLastWord(args, "biomename", "tpbiome", "stripchunk");
}
else if (args.length == 3)
{
return getListOfStringsMatchingLastWord(args, "include", "exclude");
}
return null;

View file

@ -1,9 +1,10 @@
commands.biomesoplenty.usage=/biomesoplenty <tpbiome|biomename> [args]
commands.biomesoplenty.usage=/biomesoplenty <tpbiome|biomename|stripchunk> [args]
commands.biomesoplenty.biomename.usage=/biomesoplenty biomename [biomeId]
commands.biomesoplenty.biomename.success=Biome ID %s is associated with %s
commands.biomesoplenty.tpbiome.usage=/biomesoplenty tpbiome [biomeId]
commands.biomesoplenty.tpbiome.success=Teleported %s to biome %s at (%s, %s, %s)
commands.biomesoplenty.tpbiome.error=Couldn't find biome %s!
commands.biomesoplenty.stripchunk.usage=/biomesoplenty stripchunk [radius] <include|exclude> [block] [metadata]
generator.BIOMESOP=Biomes O' Plenty
generator.BIOMESOP.info=Notice: Biomes O' Plenty 1.8 is in a very early state