diff options
| author | Jason Mitchell <mitchej@gmail.com> | 2023-01-29 22:47:18 -0800 |
|---|---|---|
| committer | Jason Mitchell <mitchej@gmail.com> | 2023-01-29 22:47:18 -0800 |
| commit | 960bbb3537d7c8c552050b5826de58bc8d798f04 (patch) | |
| tree | 8006e73e99cc48c8b401cf9b34388f9b293dd43e /src/main/java/bloodasp/galacticgreg/command/AEStorageCommand.java | |
| parent | 1e0349649cf45764435b993bc87339742a025078 (diff) | |
| download | GT5-Unofficial-960bbb3537d7c8c552050b5826de58bc8d798f04.tar.gz GT5-Unofficial-960bbb3537d7c8c552050b5826de58bc8d798f04.tar.bz2 GT5-Unofficial-960bbb3537d7c8c552050b5826de58bc8d798f04.zip | |
[ci skip] spotlessApply with the new settings
Diffstat (limited to 'src/main/java/bloodasp/galacticgreg/command/AEStorageCommand.java')
| -rw-r--r-- | src/main/java/bloodasp/galacticgreg/command/AEStorageCommand.java | 326 |
1 files changed, 160 insertions, 166 deletions
diff --git a/src/main/java/bloodasp/galacticgreg/command/AEStorageCommand.java b/src/main/java/bloodasp/galacticgreg/command/AEStorageCommand.java index e165c2ab40..8941d4813e 100644 --- a/src/main/java/bloodasp/galacticgreg/command/AEStorageCommand.java +++ b/src/main/java/bloodasp/galacticgreg/command/AEStorageCommand.java @@ -1,11 +1,8 @@ package bloodasp.galacticgreg.command; -import appeng.api.util.WorldCoord; -import appeng.items.storage.ItemSpatialStorageCell; -import bloodasp.galacticgreg.GalacticGreg; -import bloodasp.galacticgreg.auxiliary.PlayerChatHelper; -import bloodasp.galacticgreg.schematics.SpaceSchematic; -import bloodasp.galacticgreg.schematics.SpaceSchematicFactory; +import java.util.ArrayList; +import java.util.List; + import net.minecraft.block.Block; import net.minecraft.command.ICommand; import net.minecraft.command.ICommandSender; @@ -17,167 +14,164 @@ import net.minecraft.server.MinecraftServer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -import java.util.ArrayList; -import java.util.List; +import appeng.api.util.WorldCoord; +import appeng.items.storage.ItemSpatialStorageCell; +import bloodasp.galacticgreg.GalacticGreg; +import bloodasp.galacticgreg.auxiliary.PlayerChatHelper; +import bloodasp.galacticgreg.schematics.SpaceSchematic; +import bloodasp.galacticgreg.schematics.SpaceSchematicFactory; /** - * This command allows to export any structure that has been stored inside a spatial storage cell - * to a xml file that can later be enabled for spawning in dimensions. + * This command allows to export any structure that has been stored inside a spatial storage cell to a xml file that can + * later be enabled for spawning in dimensions. */ public class AEStorageCommand implements ICommand { - private List<String> aliases; - public AEStorageCommand() - { - this.aliases = new ArrayList<>(); - this.aliases.add("exportae"); - } - - @Override - public String getCommandName() - { - return "exportae"; - } - - @Override - public String getCommandUsage(ICommandSender pCommandSender) - { - return "exportae <structure name>"; - } - - @Override - public List<String> getCommandAliases() - { - return this.aliases; - } - - @Override - public void processCommand(ICommandSender pCommandSender, String[] pArgs) - { - try - { - if (pCommandSender instanceof EntityPlayer) - { - if (pArgs.length < 1) - return; - - String tName = pArgs[0]; - - EntityPlayer tEP = (EntityPlayer) pCommandSender; - // Check if item in hand is a spatial storage cell - ItemStack tIS = tEP.inventory.getCurrentItem(); - if (tIS.getItem() instanceof ItemSpatialStorageCell) - { - ItemSpatialStorageCell tCell = (ItemSpatialStorageCell) tIS.getItem(); - World tSpatialWorld = tCell.getWorld(tIS); - WorldCoord storedSize = tCell.getStoredSize(tIS); - - // Check if SSC is filled - if (storedSize.x == 0 || storedSize.y == 0 ||storedSize.z == 0) - { - PlayerChatHelper.SendError(pCommandSender, "Error: This spatial storage is empty"); - return; - } - - // Export structure - GalacticGreg.Logger.info("Creating Structure from Spatial AE drive. Dimensions: X [%d] Y [%d] Z [%d]", storedSize.x, storedSize.y, storedSize.z); - SpaceSchematic tSchematic = SpaceSchematicFactory.createSchematic(tName); - boolean tTEWarningSend = false; - - // Loop all 3 dimensions - for (int lX = 1; lX <= storedSize.x; lX++) { - for (int lY = 65; lY < 65 + storedSize.y; lY++) { - for (int lZ = 1; lZ <= storedSize.z; lZ++) { - - // Get the block - Block b = tSpatialWorld.getBlock(lX, lY, lZ); - // Get the meta - int bm = tSpatialWorld.getBlockMetadata(lX, lY, lZ); - - // Search for the blocks name - String tBlockName = Block.blockRegistry.getNameForObject(b); - - // Check if block is a tileentity - TileEntity bTE = tSpatialWorld.getTileEntity(lX, lY, lZ); - - String tMsg = String.format("[X-%d][Y-%d][Z-%d] ", lX, lY, lZ); - String nbtComp = ""; - // If block could be found... - if (b != null) - { - tMsg += tBlockName; - // If block is a TileEntity - if (bTE != null) - { - // Print a warning on the console - tMsg += " TE"; - GalacticGreg.Logger.warn("Warning: Found TileEntity at X[%d] Y[%d] Z[%d]. NBT States are not exported!", lX, lY, lZ); - if (!tTEWarningSend) - { - // Send a warning ingame, once per export command - tTEWarningSend = true; - PlayerChatHelper.SendWarn(pCommandSender, "TileEntity states are not exported!"); - } - - } - - // If the block is not air, add it to the structure - if (b != Blocks.air) - tSchematic.addStructureInfo(SpaceSchematicFactory.createStructureInfo(lX, lY, lZ, b, bm)); - } - } - } - } - - // Save structure to disk - if (!GalacticGreg.SchematicHandler.SaveSpaceStructure(tSchematic)) - { - // Something went wrong... - PlayerChatHelper.SendError(pCommandSender, "Something went wrong. Structure not saved"); - } - else - { - // All good, xml exported. Notify player that he needs to edit the file - PlayerChatHelper.SendInfo(pCommandSender, "Structure has been exported to " + tSchematic.getName() + ".xml. It contains " + tSchematic.coordInfo().size() + " Blocks"); - PlayerChatHelper.SendInfo(pCommandSender, "You have to edit the file before a reload will accept it!"); - } - } - else - PlayerChatHelper.SendError(pCommandSender, "Error: Item in your hand is not a spatial storage drive!"); - } - } - catch (Exception e) - { - e.printStackTrace(); - } - } - - @Override - public boolean canCommandSenderUseCommand(ICommandSender pCommandSender) - { - // Command is only enabled for actual players and only if they are OP-ed - if(pCommandSender instanceof EntityPlayerMP) - { - EntityPlayerMP tEP = (EntityPlayerMP)pCommandSender; - return MinecraftServer.getServer().getConfigurationManager().func_152596_g(tEP.getGameProfile()); - } - else - return false; - } - - @Override - public int compareTo(Object o) { - return 0; - } - - @SuppressWarnings("rawtypes") - @Override - public List addTabCompletionOptions(ICommandSender p_71516_1_, - String[] p_71516_2_) { - return null; - } - - @Override - public boolean isUsernameIndex(String[] p_82358_1_, int p_82358_2_) { - return false; - } -}
\ No newline at end of file + + private List<String> aliases; + + public AEStorageCommand() { + this.aliases = new ArrayList<>(); + this.aliases.add("exportae"); + } + + @Override + public String getCommandName() { + return "exportae"; + } + + @Override + public String getCommandUsage(ICommandSender pCommandSender) { + return "exportae <structure name>"; + } + + @Override + public List<String> getCommandAliases() { + return this.aliases; + } + + @Override + public void processCommand(ICommandSender pCommandSender, String[] pArgs) { + try { + if (pCommandSender instanceof EntityPlayer) { + if (pArgs.length < 1) return; + + String tName = pArgs[0]; + + EntityPlayer tEP = (EntityPlayer) pCommandSender; + // Check if item in hand is a spatial storage cell + ItemStack tIS = tEP.inventory.getCurrentItem(); + if (tIS.getItem() instanceof ItemSpatialStorageCell) { + ItemSpatialStorageCell tCell = (ItemSpatialStorageCell) tIS.getItem(); + World tSpatialWorld = tCell.getWorld(tIS); + WorldCoord storedSize = tCell.getStoredSize(tIS); + + // Check if SSC is filled + if (storedSize.x == 0 || storedSize.y == 0 || storedSize.z == 0) { + PlayerChatHelper.SendError(pCommandSender, "Error: This spatial storage is empty"); + return; + } + + // Export structure + GalacticGreg.Logger.info( + "Creating Structure from Spatial AE drive. Dimensions: X [%d] Y [%d] Z [%d]", + storedSize.x, + storedSize.y, + storedSize.z); + SpaceSchematic tSchematic = SpaceSchematicFactory.createSchematic(tName); + boolean tTEWarningSend = false; + + // Loop all 3 dimensions + for (int lX = 1; lX <= storedSize.x; lX++) { + for (int lY = 65; lY < 65 + storedSize.y; lY++) { + for (int lZ = 1; lZ <= storedSize.z; lZ++) { + + // Get the block + Block b = tSpatialWorld.getBlock(lX, lY, lZ); + // Get the meta + int bm = tSpatialWorld.getBlockMetadata(lX, lY, lZ); + + // Search for the blocks name + String tBlockName = Block.blockRegistry.getNameForObject(b); + + // Check if block is a tileentity + TileEntity bTE = tSpatialWorld.getTileEntity(lX, lY, lZ); + + String tMsg = String.format("[X-%d][Y-%d][Z-%d] ", lX, lY, lZ); + String nbtComp = ""; + // If block could be found... + if (b != null) { + tMsg += tBlockName; + // If block is a TileEntity + if (bTE != null) { + // Print a warning on the console + tMsg += " TE"; + GalacticGreg.Logger.warn( + "Warning: Found TileEntity at X[%d] Y[%d] Z[%d]. NBT States are not exported!", + lX, + lY, + lZ); + if (!tTEWarningSend) { + // Send a warning ingame, once per export command + tTEWarningSend = true; + PlayerChatHelper + .SendWarn(pCommandSender, "TileEntity states are not exported!"); + } + + } + + // If the block is not air, add it to the structure + if (b != Blocks.air) tSchematic.addStructureInfo( + SpaceSchematicFactory.createStructureInfo(lX, lY, lZ, b, bm)); + } + } + } + } + + // Save structure to disk + if (!GalacticGreg.SchematicHandler.SaveSpaceStructure(tSchematic)) { + // Something went wrong... + PlayerChatHelper.SendError(pCommandSender, "Something went wrong. Structure not saved"); + } else { + // All good, xml exported. Notify player that he needs to edit the file + PlayerChatHelper.SendInfo( + pCommandSender, + "Structure has been exported to " + tSchematic.getName() + + ".xml. It contains " + + tSchematic.coordInfo().size() + + " Blocks"); + PlayerChatHelper + .SendInfo(pCommandSender, "You have to edit the file before a reload will accept it!"); + } + } else PlayerChatHelper + .SendError(pCommandSender, "Error: Item in your hand is not a spatial storage drive!"); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Override + public boolean canCommandSenderUseCommand(ICommandSender pCommandSender) { + // Command is only enabled for actual players and only if they are OP-ed + if (pCommandSender instanceof EntityPlayerMP) { + EntityPlayerMP tEP = (EntityPlayerMP) pCommandSender; + return MinecraftServer.getServer().getConfigurationManager().func_152596_g(tEP.getGameProfile()); + } else return false; + } + + @Override + public int compareTo(Object o) { + return 0; + } + + @SuppressWarnings("rawtypes") + @Override + public List addTabCompletionOptions(ICommandSender p_71516_1_, String[] p_71516_2_) { + return null; + } + + @Override + public boolean isUsernameIndex(String[] p_82358_1_, int p_82358_2_) { + return false; + } +} |
