Advertisement
xXm0dzXx

mod_Builders

Mar 10th, 2013
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 44.43 KB | None | 0 0
  1. package net.minecraft.src;
  2. // Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
  3. // Jad home page: http://www.kpdus.com/jad.html
  4. // Decompiler options: packimports(3) braces deadcode
  5.  
  6. import java.io.BufferedReader;
  7. import java.io.File;
  8. import java.io.FileInputStream;
  9. import java.io.FileNotFoundException;
  10. import java.io.FileOutputStream;
  11. import java.io.FileReader;
  12. import java.io.FileWriter;
  13. import java.io.IOException;
  14. import java.util.ArrayList;
  15. import java.util.List;
  16. import java.util.Map;
  17. import java.util.Random;
  18.  
  19. import net.minecraft.client.Minecraft;
  20. import net.minecraft.client.gui.GuiIngameMenu;
  21. import net.minecraft.client.gui.GuiScreen;
  22. import net.minecraft.client.gui.inventory.GuiEditSign;
  23. import net.minecraft.client.model.ModelBiped;
  24. import net.minecraft.client.renderer.entity.RenderBiped;
  25. import net.minecraft.entity.Entity;
  26. import net.minecraft.entity.EntityList;
  27. import net.minecraft.entity.EntityLiving;
  28. import net.minecraft.entity.EnumCreatureType;
  29. import net.minecraft.entity.item.EntityItem;
  30. import net.minecraft.entity.player.EntityPlayer;
  31. import net.minecraft.item.ItemStack;
  32. import net.minecraft.nbt.CompressedStreamTools;
  33. import net.minecraft.nbt.NBTTagCompound;
  34. import net.minecraft.nbt.NBTTagList;
  35. import net.minecraft.tileentity.TileEntitySign;
  36. import net.minecraft.util.ChunkCoordinates;
  37. import net.minecraft.util.EnumMovingObjectType;
  38. import net.minecraft.util.MathHelper;
  39. import net.minecraft.world.World;
  40. import net.minecraft.world.biome.BiomeGenBase;
  41. import net.minecraft.world.storage.SaveHandler;
  42.  
  43. import org.lwjgl.input.Mouse;
  44.  
  45. public class mod_Builders extends BaseMod
  46. {
  47.  
  48.     Minecraft mc = ModLoader.getMinecraftInstance();
  49.    
  50.     @Override
  51.     public void load()
  52.     {
  53.         builderCount = 0;
  54.         minecraft_b = ModLoader.getMinecraftInstance();
  55.         BLDRBlueprints.singlePrints = new ArrayList<ArrayList<ArrayList<ArrayList<Short>>>>();
  56.         builderList = new ArrayList<BLDREntityBuilder>();
  57.         assistants = new ArrayList<BLDREntityBuilder>();
  58.         BLDRBlueprints.singlePrintNames = new ArrayList<String>();
  59.  
  60.         coords = new ChunkCoordinates();
  61.         coordsT = false;
  62.         blockT = false;
  63.        
  64.         ModLoader.setInGameHook(this, true, true);
  65.         ModLoader.setInGUIHook(this, true, true);
  66.        
  67.         System.out.println("Debug test");
  68.         ModLoader.registerEntityID(BLDREntityBrickBuilder.class, "BrickBuilder", ModLoader.getUniqueEntityId(), 0x4D3C42, 0x4D3C42);
  69.         ModLoader.registerEntityID(BLDREntityCobbleBuilder.class, "CobbleBuilder", ModLoader.getUniqueEntityId(), 0x4D3C42, 0x4D3C42);
  70.         ModLoader.registerEntityID(BLDREntityExplorer.class, "Explorer", ModLoader.getUniqueEntityId(), 0x4D3C42, 0x4D3C42);
  71.         ModLoader.registerEntityID(BLDREntityHomeSeeker.class, "HomeSeeker", ModLoader.getUniqueEntityId(), 0x4D3C42, 0x4D3C42);
  72.         ModLoader.registerEntityID(BLDREntityTreasureHunter.class, "TreasureHunter", ModLoader.getUniqueEntityId(), 0x4D3C42, 0x4D3C42);
  73.         ModLoader.registerEntityID(BLDREntityMayor.class, "Mayor", ModLoader.getUniqueEntityId(), 0x4D3C42, 0x4D3C42);
  74.         ModLoader.registerEntityID(BLDREntityMultiBuilder.class, "MultiBuilder", ModLoader.getUniqueEntityId(), 0x4D3C42, 0x4D3C42);
  75.         ModLoader.registerEntityID(BLDREntityTrader.class, "Trader", ModLoader.getUniqueEntityId(), 0x4D3C42, 0x4D3C42);
  76.         ModLoader.registerEntityID(BLDREntityBaker.class, "Baker", ModLoader.getUniqueEntityId(), 0x4D3C42, 0x4D3C42);
  77.         ModLoader.registerEntityID(BLDREntitySandBuilder.class, "SandBuilder", ModLoader.getUniqueEntityId(), 0x4D3C42, 0x4D3C42);
  78.        
  79.         /*ModLoader.addSpawn(BLDREntityBrickBuilder.class, 10, 0, 0, EnumCreatureType.creature);
  80.         ModLoader.addSpawn(BLDREntityCobbleBuilder.class, 10, 0, 0, EnumCreatureType.creature);
  81.         ModLoader.addSpawn(BLDREntityExplorer.class, 10, 0, 0, EnumCreatureType.creature);
  82.         ModLoader.addSpawn(BLDREntityHomeSeeker.class, 10, 0, 0, EnumCreatureType.creature);
  83.         ModLoader.addSpawn(BLDREntityTreasureHunter.class, 10, 0, 0, EnumCreatureType.creature);
  84.         ModLoader.addSpawn(BLDREntityMayor.class, 10, 0, 0, EnumCreatureType.creature);
  85.         ModLoader.addSpawn(BLDREntityMultiBuilder.class, 10, 0, 0, EnumCreatureType.creature);
  86.         ModLoader.addSpawn(BLDREntityTrader.class, 10, 0, 0, EnumCreatureType.creature);
  87.         ModLoader.addSpawn(BLDREntityBaker.class, 10, 0, 0, EnumCreatureType.creature);
  88.         ModLoader.addSpawn(BLDREntitySandBuilder.class, 10, 0, 0, EnumCreatureType.creature, new BiomeGenBase[]{BiomeGenBase.desert});*/
  89.  
  90.         //if index nonexistant, will stay -1
  91.         BLDRBlueprints.initSpecial();
  92.        
  93.         //setDefaultSettings();
  94.         File f = null;
  95.         File source = null;
  96.         File srcDirectory;
  97.         File srcDirectory2;
  98.         File srcDirectory3;
  99.         File singlePrintsDirectory;
  100.         folderDetected = false;
  101.         try{
  102.             source = new File(ModLoader.class.getProtectionDomain().getCodeSource().getLocation().toURI());
  103.             //srcDirectory = source.getParentFile().getParentFile(); //.minecraft folder
  104.             srcDirectory2 = new File((new StringBuilder()).append(Minecraft.getMinecraftDir()).append("/mods/Builders").toString()); //mods/Builders folder
  105.             if(srcDirectory2.exists() && srcDirectory2.isDirectory()){
  106.                 srcDirectory3 = new File((new StringBuilder()).append(Minecraft.getMinecraftDir()).append("/mods/Builders/BuilderConfiguration.txt").toString()); //mods/Builders config
  107.                 if(srcDirectory3.exists())
  108.                 {
  109.                     folderDetected = true;
  110.                     f = new File(srcDirectory2, "BuilderConfiguration.txt"); //load config file
  111.                     singlePrintsDirectory = new File(srcDirectory2, "SinglePrints");
  112.                     if(singlePrintsDirectory.exists() && singlePrintsDirectory.isDirectory())
  113.                         loadAllSingleBlueprints(singlePrintsDirectory.listFiles());
  114.                 } else {
  115.                     System.out.println("Config not detected.");
  116.                 }
  117.             } else if (!srcDirectory2.exists())
  118.             {
  119.                 System.out.println("Builders folder not detected... Creating.");
  120.                 new File( String.valueOf( srcDirectory2 ) ).mkdir();
  121.                 new File( String.valueOf( srcDirectory2 ) + "/MultiPrints" ).mkdir();
  122.                 new File( String.valueOf( srcDirectory2 ) + "/SinglePrints" ).mkdir();
  123.             }
  124.            
  125.             if (!folderDetected)
  126.             {
  127.                 System.out.println("Builders not installed correctly!");
  128.             }
  129.                
  130.            
  131.         }catch(Exception e){
  132.             setDefaultSettings();
  133.         }finally{
  134.         //load configuration file
  135.         if(f != null && f.exists())
  136.             setConfigurationSettings(f);
  137.         else
  138.             setDefaultSettings();
  139.         }
  140.        
  141.         signEdit = false;
  142.         sign = null;
  143.         saveSignList = false;
  144.         loadSignList = false;
  145.         world = null;
  146.        
  147.  
  148.     }
  149.    
  150.    private void signsListLoad(){
  151.        if(world == null) return;
  152.        //create fresh new signsList
  153.        signsList = new ArrayList<BLDRBuilderSigns>();
  154.        try{
  155.            //open saved sign file; if does not exist, end method
  156.            File file3 = new File(((SaveHandler)world.getSaveHandler()).getSaveDirectory(), "builderSigns.dat"); //signs file
  157.            if(file3 == null || !file3.exists())
  158.                return;
  159.            
  160.            FileInputStream fileinputstream = new FileInputStream(file3);
  161.            NBTTagCompound nbttagcompound = CompressedStreamTools.readCompressed(fileinputstream);
  162.            
  163.            NBTTagList nbttaglist = nbttagcompound.getTagList("Signs");
  164.            //read data from file until at end of file
  165.            ////add Sign to list using coordinates, type, range, num1, and num2
  166.            for(int i = 0; i < nbttaglist.tagCount(); i++)
  167.            {
  168.                NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbttaglist.tagAt(i);
  169.                BLDRBuilderSigns b = new BLDRBuilderSigns();
  170.                b.readFromNBT(nbttagcompound1);
  171.                b.world = world;
  172.                signsList.add(b);
  173.            }
  174.        }catch(Exception e){
  175.            e.printStackTrace();
  176.        }
  177.    }
  178.    
  179.    private void signsListSave(){
  180.        //if signList empty or non-existent, exit
  181.        if(signsList == null || signsList.size() < 1)
  182.            return;
  183.        try{
  184.            //create or replace sign file
  185.            File file3 = new File(((SaveHandler)world.getSaveHandler()).getSaveDirectory(), "builderSigns.dat"); //signs file
  186.            if(file3.exists())
  187.                file3.delete();
  188.            FileOutputStream fileoutputstream = new FileOutputStream(file3);
  189.        
  190.            //copy data from each sign on the list into file, until end of list
  191.            ////save coordinates, type, range, num1, and num2 to file
  192.            NBTTagCompound nbttagcompound = new NBTTagCompound();
  193.            NBTTagList nbttaglist = new NBTTagList();
  194.            for(int i = 0; i < signsList.size(); i++)
  195.            {
  196.                BLDRBuilderSigns b = signsList.get(i);
  197.                if(b != null)
  198.                {
  199.                    NBTTagCompound nbttagcompound1 = new NBTTagCompound();
  200.                    b.writeToNBT(nbttagcompound1);
  201.                    nbttaglist.appendTag(nbttagcompound1);
  202.                }
  203.            }
  204.            nbttagcompound.setTag("Signs", nbttaglist);
  205.            CompressedStreamTools.writeCompressed(nbttagcompound, fileoutputstream);
  206.        }catch(Exception e){
  207.            e.printStackTrace();
  208.        }
  209.    }
  210.    
  211.  
  212.    public boolean onTickInGUI(float f, Minecraft game, GuiScreen gui)
  213.    {
  214.        if(world != null && world.isRemote || game.thePlayer != null && game.thePlayer.dimension != 0) return true;
  215.         //Get Sign Edit Screen's SignTileEntity, if not already obtained
  216.         if(signEdit == false && gui instanceof GuiEditSign){
  217.             try {
  218.                 sign = (TileEntitySign) ModLoader.getPrivateValue(GuiEditSign.class, (GuiEditSign)gui, "b");
  219.                 signEdit = true;
  220.             } catch (Throwable e) {
  221.             }
  222.         }
  223.         //Save signsList variable when at menu screen
  224.         else if(saveSignList == false && gui instanceof GuiIngameMenu){
  225.             signsListSave();
  226.             saveSignList = true;
  227.         }
  228.  
  229.         return true;
  230.    }
  231.    
  232.    public boolean onTickInGame(float f, Minecraft game)
  233.    {
  234.        if(world != null && world.isRemote || game.thePlayer != null && game.thePlayer.dimension != 0) return true;
  235.        
  236.      //if world has just been loaded, or has changed, set world variable to that world
  237.     if(game.theWorld != world){
  238.         world = game.theWorld;
  239.         builderCount = 0;
  240.         builderList.clear();
  241.         assistants.clear();
  242.         signEdit = false;
  243.            sign = null;
  244.            saveSignList = false;
  245.            loadSignList = false;
  246.            if(folderDetected) this.mc.thePlayer.addChatMessage("Builders Mod: Mod properly installed and functioning.");
  247.            else this.mc.thePlayer.addChatMessage("Builders Mod: <WARNING> Builders folder not detected in .minecraft/bin folder.  Mod will not function correctly without this folder.");
  248.            
  249.          //set minecraft instance if not already set
  250.             if(mod_Builders.minecraft_b == null || mod_Builders.minecraft_b != game)
  251.                 mod_Builders.minecraft_b = game;
  252.     }
  253.    
  254.   //After sign screen removed, check sign's text, and add to sign List if applicable
  255.     if(game.currentScreen == null){
  256.         if(signEdit == true){
  257.             BLDRBuilderSigns b = new BLDRBuilderSigns();
  258.             if(b.createBuilderSign(sign))
  259.                 signsList.add(b);
  260.             sign = null;
  261.             signEdit = false;
  262.         }
  263.        
  264.         //reset save variable
  265.         else if(saveSignList == true)
  266.             saveSignList = false;
  267.        
  268.         //if not loaded signs, load signs from file
  269.         else if(loadSignList == false){
  270.             signsListLoad();
  271.             loadSignList = true;
  272.         }
  273.     }
  274.    
  275.     if(world.getWorldTime() % 10 == 0){
  276.         try {
  277.             performBuilderSpawning(game);
  278.         } catch (Exception e) {
  279.             e.printStackTrace();
  280.         }
  281.     }
  282.    
  283.     if(builderCount != 0) refreshBuilderList();
  284.     builderCount = builderList.size();
  285.    
  286.     //////TELL FOLLOWERS TO AID
  287.    
  288.     EntityPlayer ep = game.thePlayer;
  289.  
  290.     if(game.theWorld.isRemote || game.currentScreen != null || ep == null || !game.inGameHasFocus) return true;
  291.  
  292.     boolean leftClicking = Mouse.isButtonDown(0); //true if player holding down left mouse button
  293.     boolean rightClicking = Mouse.isButtonDown(1);
  294.    
  295.     //checks to see if player's cursor is over an entity or a block
  296.     entityTarget = game.objectMouseOver != null && game.objectMouseOver.typeOfHit == EnumMovingObjectType.ENTITY ? game.objectMouseOver.entityHit : null;
  297.     if(game.objectMouseOver != null && game.objectMouseOver.typeOfHit == EnumMovingObjectType.TILE){
  298.         blockT = true;
  299.     }
  300.     else
  301.         blockT = false;
  302.     ItemStack it = ep.getCurrentEquippedItem();
  303.    
  304.     if(leftClicking && entityTarget != null)
  305.         for(int i = 0; i < assistants.size(); i++)
  306.             assistants.get(i).playerEntityAttack(entityTarget);
  307.    
  308.     return true;
  309.    }
  310.    
  311.  //refreshes the builder list
  312.     private void refreshBuilderList(){
  313.         builderList.clear();
  314.         BLDREntityBuilder eb;
  315.         for(int i = 0; i < world.loadedEntityList.size(); i++){
  316.             if(world.loadedEntityList.get(i) instanceof BLDREntityBuilder){
  317.                 eb = (BLDREntityBuilder) world.loadedEntityList.get(i);
  318.                 if(((eb.builderFlags >> 2) & 1) != 1 && !eb.isDead) builderList.add(eb);
  319.             }
  320.         }
  321.     }
  322.    
  323.    //adds all builder limits together
  324.    private int addLimits(){
  325.        if(world.isDaytime()){
  326.            return BLDRBuilderConfig.getMaxTotalDayTime();
  327.        }
  328.        else{
  329.            return BLDRBuilderConfig.getMaxTotalNightTime();
  330.        }
  331.    }
  332.  //spawns builders into world
  333.     private void performBuilderSpawning(Minecraft game) throws Exception{
  334.         if(builderList.size() > addLimits() || game.thePlayer == null) return;
  335.        
  336.         int chunkX = MathHelper.floor_double(game.thePlayer.posX / 16.0D);
  337.         int chunkZ = MathHelper.floor_double(game.thePlayer.posZ / 16.0D);
  338.        
  339.         //choose random chunk to spawn builders at
  340.         chunkX += world.rand.nextInt(11) - 5;
  341.         chunkZ += world.rand.nextInt(11) - 5;
  342.        
  343.         //choose random coordinates in chunk to spawn builders at
  344.         int x = (chunkX * 16) + world.rand.nextInt(16);
  345.         int y = world.rand.nextInt(63) + 64;
  346.         int z = (chunkZ * 16) + world.rand.nextInt(16);
  347.         while(game.thePlayer.getDistance(x, y, z) < 20D) //make builders spawn somewhat far from player
  348.             x += 8 + world.rand.nextInt(10);
  349.         while(world.isAirBlock(x, y - 1, z) && y > 10)
  350.             y -= 5;
  351.         BLDREntityBuilder eb;
  352.         //spawn multiple builders near that location
  353.         for(int i = 0; i < (BLDRBuilderConfig.freeLanceStyle > 1 ? 16 : 8); i++){
  354.             eb = (BLDREntityBuilder) builderTypes[world.rand.nextInt(builderTypes.length)].getConstructor(World.class).newInstance(world);
  355.             int xx = x + world.rand.nextInt(15) - 7;
  356.             int yy = y + world.rand.nextInt(5) - 2;
  357.             int zz = z + world.rand.nextInt(15) - 7;
  358.  
  359.             while(world.isAirBlock(xx, yy - 1, zz) && yy > 10)
  360.                 yy--;
  361.             while(!world.isAirBlock(xx, yy, zz) && yy < 120)
  362.                 yy++;
  363.  
  364.             eb.setLocationAndAngles(xx, (double)yy + 1.3, zz, world.rand.nextFloat() * 360.0F, 0.0F);
  365.             if(canBeSpawned(eb)){
  366.                 if(world.getWorldInfo().getWorldName() == "BuilderDebug"){
  367.                     String str = new StringBuilder("Builder spawned: ").append(xx).append(" ").append((double)yy + 1.3).append(" ").append(zz).toString();
  368.                     ModLoader.getMinecraftInstance().thePlayer.addChatMessage(str);
  369.                 }
  370.                 builderList.add(eb);
  371.                 world.spawnEntityInWorld(eb);
  372.             }
  373.         }
  374.     }
  375.    
  376.     private boolean canBeSpawned(BLDREntityBuilder eb){
  377.         return eb.getCanSpawnHere() && (BLDRBuilderConfig.freeLanceStyle != 2 || eb.withinBuildRegion((int) (eb.posX / 16), (int) (eb.posZ / 16))) && (BLDRBuilderConfig.freeLanceStyle != 3 || eb.withinBuildRegion((int) (eb.posX / 16) + eb.getChunkOffsetX(), (int) (eb.posZ / 16) + eb.getChunkOffsetZ()));
  378.     }
  379.    
  380.      public static int countBuilders(Class class1)
  381.         {
  382.             int i = 0;
  383.             for(int j = 0; j < builderList.size(); j++)
  384.             {
  385.                 Entity entity = (Entity)builderList.get(j);
  386.                 if(class1.isAssignableFrom(entity.getClass()))
  387.                 {
  388.                     i++;
  389.                 }
  390.             }
  391.  
  392.             return i;
  393.         }
  394.    
  395.    
  396.     private void setConfigurationSettings(File f){
  397.         BufferedReader br = null;
  398.         try{
  399.             br = new BufferedReader(new FileReader(f));
  400.             String thisLine;
  401.            
  402.             //set each static value (see setDefaultSettings() for identifications)
  403.             //Spawn Rates
  404.             thisLine = br.readLine();
  405.             thisLine = br.readLine();
  406.             thisLine = br.readLine();
  407.             BLDRBuilderConfig.brickSpawnRateDay = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  408.             thisLine = br.readLine();
  409.             BLDRBuilderConfig.brickSpawnRateNight = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  410.             thisLine = br.readLine();
  411.             BLDRBuilderConfig.cobbleSpawnRateDay = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  412.             thisLine = br.readLine();
  413.             BLDRBuilderConfig.cobbleSpawnRateNight = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  414.             thisLine = br.readLine();
  415.             BLDRBuilderConfig.explorerSpawnRateDay = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  416.             thisLine = br.readLine();
  417.             BLDRBuilderConfig.explorerSpawnRateNight = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  418.             thisLine = br.readLine();
  419.             BLDRBuilderConfig.homeSpawnRateDay = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  420.             thisLine = br.readLine();
  421.             BLDRBuilderConfig.homeSpawnRateNight = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  422.             thisLine = br.readLine();
  423.             BLDRBuilderConfig.treasureSpawnRateDay = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  424.             thisLine = br.readLine();
  425.             BLDRBuilderConfig.treasureSpawnRateNight = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  426.             thisLine = br.readLine();
  427.             BLDRBuilderConfig.mayorSpawnRateDay = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  428.             thisLine = br.readLine();
  429.             BLDRBuilderConfig.mayorSpawnRateNight = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  430.             thisLine = br.readLine();
  431.             BLDRBuilderConfig.multiSpawnRateDay = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  432.             thisLine = br.readLine();
  433.             BLDRBuilderConfig.multiSpawnRateNight = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  434.             thisLine = br.readLine();
  435.             BLDRBuilderConfig.traderSpawnRateDay = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  436.             thisLine = br.readLine();
  437.             BLDRBuilderConfig.traderSpawnRateNight = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  438.             thisLine = br.readLine();
  439.             BLDRBuilderConfig.bakerSpawnRateDay = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  440.             thisLine = br.readLine();
  441.             BLDRBuilderConfig.bakerSpawnRateNight = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  442.             thisLine = br.readLine();
  443.             BLDRBuilderConfig.sandSpawnRateDay = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  444.             thisLine = br.readLine();
  445.             BLDRBuilderConfig.sandSpawnRateNight = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  446.  
  447.             //Spawn Limits
  448.             thisLine = br.readLine();
  449.             thisLine = br.readLine();
  450.             BLDRBuilderConfig.brickSpawnMaxDay = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  451.             thisLine = br.readLine();
  452.             BLDRBuilderConfig.brickSpawnMaxNight = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  453.             thisLine = br.readLine();
  454.             BLDRBuilderConfig.cobbleSpawnMaxDay = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  455.             thisLine = br.readLine();
  456.             BLDRBuilderConfig.cobbleSpawnMaxNight = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  457.             thisLine = br.readLine();
  458.             BLDRBuilderConfig.explorerSpawnMaxDay = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  459.             thisLine = br.readLine();
  460.             BLDRBuilderConfig.explorerSpawnMaxNight = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  461.             thisLine = br.readLine();
  462.             BLDRBuilderConfig.homeSpawnMaxDay = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  463.             thisLine = br.readLine();
  464.             BLDRBuilderConfig.homeSpawnMaxNight = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  465.             thisLine = br.readLine();
  466.             BLDRBuilderConfig.treasureSpawnMaxDay = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  467.             thisLine = br.readLine();
  468.             BLDRBuilderConfig.treasureSpawnMaxNight = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  469.             thisLine = br.readLine();
  470.             BLDRBuilderConfig.mayorSpawnMaxDay = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  471.             thisLine = br.readLine();
  472.             BLDRBuilderConfig.mayorSpawnMaxNight = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  473.             thisLine = br.readLine();
  474.             BLDRBuilderConfig.multiSpawnMaxDay = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  475.             thisLine = br.readLine();
  476.             BLDRBuilderConfig.multiSpawnMaxNight = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  477.             thisLine = br.readLine();
  478.             BLDRBuilderConfig.traderSpawnMaxDay = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  479.             thisLine = br.readLine();
  480.             BLDRBuilderConfig.traderSpawnMaxNight = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  481.             thisLine = br.readLine();
  482.             BLDRBuilderConfig.bakerSpawnMaxDay = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  483.             thisLine = br.readLine();
  484.             BLDRBuilderConfig.bakerSpawnMaxNight = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  485.             thisLine = br.readLine();
  486.             BLDRBuilderConfig.sandSpawnMaxDay = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  487.             thisLine = br.readLine();
  488.             BLDRBuilderConfig.sandSpawnMaxNight = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  489.            
  490.             //Structure Limits
  491.             thisLine = br.readLine();
  492.             thisLine = br.readLine();
  493.             BLDRBuilderConfig.brickStructureLimit = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  494.             thisLine = br.readLine();
  495.             BLDRBuilderConfig.cobbleStructureLimit = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  496.             thisLine = br.readLine();
  497.             BLDRBuilderConfig.explorerBlockLimit = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  498.             thisLine = br.readLine();
  499.             BLDRBuilderConfig.homeStructureLimit = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  500.             thisLine = br.readLine();
  501.             BLDRBuilderConfig.multiStructureLimit = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  502.             thisLine = br.readLine();
  503.             BLDRBuilderConfig.sandStructureLimit = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  504.            
  505.             //Build Blocks
  506.             thisLine = br.readLine();
  507.             thisLine = br.readLine();
  508.             BLDRBuilderConfig.brickCommonBlock = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  509.             thisLine = br.readLine();
  510.             BLDRBuilderConfig.brickRareBlock = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  511.             thisLine = br.readLine();
  512.             BLDRBuilderConfig.cobbleCommonBlock = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  513.             thisLine = br.readLine();
  514.             BLDRBuilderConfig.cobbleRareBlock = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  515.             thisLine = br.readLine();
  516.             BLDRBuilderConfig.homeCommonBlock = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  517.             thisLine = br.readLine();
  518.             BLDRBuilderConfig.homeRareBlock = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  519.             thisLine = br.readLine();
  520.             BLDRBuilderConfig.explorerBlock = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  521.             thisLine = br.readLine();
  522.             BLDRBuilderConfig.explorerMBlock = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  523.             thisLine = br.readLine();
  524.             BLDRBuilderConfig.treasureMBlock = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  525.             thisLine = br.readLine();
  526.             BLDRBuilderConfig.traderBlock = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  527.             thisLine = br.readLine();
  528.             BLDRBuilderConfig.bakerBlock = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  529.             thisLine = br.readLine();
  530.             BLDRBuilderConfig.sandBlock = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  531.            
  532.             //Misc
  533.             thisLine = br.readLine();
  534.             thisLine = br.readLine();
  535.             int temp1 = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  536.             if(temp1 == 0)
  537.                 BLDRBuilderConfig.buildAnywhere = false;
  538.             else
  539.                 BLDRBuilderConfig.buildAnywhere = true;
  540.  
  541.             thisLine = br.readLine();
  542.             temp1 = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  543.             if(temp1 == 0)
  544.                 BLDRBuilderConfig.enableNames = false;
  545.             else
  546.                 BLDRBuilderConfig.enableNames = true;
  547.            
  548.             thisLine = br.readLine();
  549.             temp1 = Integer.valueOf(thisLine.split(":")[1].trim()).intValue();
  550.             if(temp1 < 0)
  551.                 BLDRBuilderConfig.freeLanceStyle = 0;
  552.             else if(temp1 > 3)
  553.                 BLDRBuilderConfig.freeLanceStyle = 3;
  554.             else
  555.                 BLDRBuilderConfig.freeLanceStyle = (byte) temp1;
  556.            
  557.            
  558.             thisLine = br.readLine();
  559.             if(thisLine != null)
  560.                 setDefaultSettings();
  561.  
  562.            
  563.            
  564.         }catch(FileNotFoundException e) {
  565.             setDefaultSettings();
  566.             if (br != null)
  567.                 try {
  568.                     br.close();
  569.                 }
  570.                 catch (IOException localIOException2)
  571.                 {
  572.                 }
  573.         }catch (IOException e)
  574.         {
  575.             setDefaultSettings();
  576.             if (br != null)
  577.             try {
  578.                 br.close();
  579.             }
  580.             catch (IOException localIOException3)
  581.             {
  582.             }
  583.         }
  584.         finally
  585.         {
  586.             if (br != null)
  587.             try {
  588.                 br.close();
  589.             } catch (IOException localIOException4) {
  590.             }
  591.         }
  592.     }
  593.    
  594.     private void setDefaultSettings(){
  595.             //Spawn stuff
  596.        
  597.         //Spawn rates for each builder (0 - 100), 0 = never, 100 = always
  598.         BLDRBuilderConfig.brickSpawnRateDay = 75; //BrickBuilder (Day)
  599.         BLDRBuilderConfig.brickSpawnRateNight = 0; //BrickBuilder (Night)
  600.         BLDRBuilderConfig.cobbleSpawnRateDay = 90; //CobbleBuilder (Day)
  601.         BLDRBuilderConfig.cobbleSpawnRateNight = 20; //CobbleBuilder (Night)
  602.         BLDRBuilderConfig.explorerSpawnRateDay = 10; //Explorer (Day)
  603.         BLDRBuilderConfig.explorerSpawnRateNight = 90; //Explorer (Night)
  604.         BLDRBuilderConfig.homeSpawnRateDay = 60; //Home Seeker (Day)
  605.         BLDRBuilderConfig.homeSpawnRateNight = 10; //Home Seeker (Night)
  606.         BLDRBuilderConfig.treasureSpawnRateDay = 0; //Treasure Hunter (Day)
  607.         BLDRBuilderConfig.treasureSpawnRateNight = 0; //Treasure Hunter (Night)
  608.         BLDRBuilderConfig.mayorSpawnRateDay = 50; //Mayor (Day)
  609.         BLDRBuilderConfig.mayorSpawnRateNight = 10; //Mayor (Night)
  610.         BLDRBuilderConfig.multiSpawnRateDay = 75; //MultiBuilder (Day)
  611.         BLDRBuilderConfig.multiSpawnRateNight = 40; //MultiBuilder (Night)
  612.         BLDRBuilderConfig.traderSpawnRateDay = 0; //Trader (Day)
  613.         BLDRBuilderConfig.traderSpawnRateNight = 0; //Trader (Night)
  614.         BLDRBuilderConfig.bakerSpawnRateDay = 0; //Baker (Day)
  615.         BLDRBuilderConfig.bakerSpawnRateNight = 0; //Baker (Night)
  616.         BLDRBuilderConfig.sandSpawnRateDay = 75; //SandBuilder (Day)
  617.         BLDRBuilderConfig.sandSpawnRateNight = 75; //SandBuilder (Night)
  618.        
  619.         //Maximum spawn for each Builder (0 - 100), 0 = no regular spawns; only created via conversion
  620.         BLDRBuilderConfig.brickSpawnMaxDay = 3; //BrickBuilder (Day)
  621.         BLDRBuilderConfig.brickSpawnMaxNight = 0; //BrickBuilder (Night)
  622.         BLDRBuilderConfig.cobbleSpawnMaxDay = 3; //CobbleBuilder (Day)
  623.         BLDRBuilderConfig.cobbleSpawnMaxNight = 3; //CobbleBuilder (Night)
  624.         BLDRBuilderConfig.explorerSpawnMaxDay = 3; //Explorer (Day)
  625.         BLDRBuilderConfig.explorerSpawnMaxNight = 6; //Explorer (Night)
  626.         BLDRBuilderConfig.homeSpawnMaxDay = 4; //Home Seeker (Day)
  627.         BLDRBuilderConfig.homeSpawnMaxNight = 4; //Home Seeker (Night)
  628.         BLDRBuilderConfig.treasureSpawnMaxDay = 0; //Treasure Hunter (Day)
  629.         BLDRBuilderConfig.treasureSpawnMaxNight = 0; //Treasure Hunter (Night)
  630.         BLDRBuilderConfig.mayorSpawnMaxDay = 1; //Mayor (Day)
  631.         BLDRBuilderConfig.mayorSpawnMaxNight = 1; //Mayor (Night)
  632.         BLDRBuilderConfig.multiSpawnMaxDay = 3; //MultiBuilder (Day)
  633.         BLDRBuilderConfig.multiSpawnMaxNight = 3; //MultiBuilder (Night)
  634.         BLDRBuilderConfig.traderSpawnMaxDay = 0; //Trader (Day)
  635.         BLDRBuilderConfig.traderSpawnMaxNight = 0; //Trader (Night)
  636.         BLDRBuilderConfig.bakerSpawnMaxDay = 0; //Baker (Day)
  637.         BLDRBuilderConfig.bakerSpawnMaxNight = 0; //Baker (Night)
  638.         BLDRBuilderConfig.sandSpawnMaxDay = 5; //SandBuilder (Day)
  639.         BLDRBuilderConfig.sandSpawnMaxNight = 5; //SandBuilder (Night)
  640.        
  641.         //Structure Limits for each Builder
  642.         BLDRBuilderConfig.brickStructureLimit = 4; //BrickBuilder Structure Limit
  643.         BLDRBuilderConfig.cobbleStructureLimit = 2; //CobbleBuilder Structure Limit
  644.         BLDRBuilderConfig.explorerBlockLimit = 16; //Explorer Structure Limit
  645.         BLDRBuilderConfig.homeStructureLimit = 2; //Home Seeker Structure Limit
  646.         BLDRBuilderConfig.multiStructureLimit = 3; //MultiBuilder Structure Limit
  647.         BLDRBuilderConfig.sandStructureLimit = 3; //MultiBuilder Structure Limit
  648.        
  649.         //Build Block for each Builder (Block ID; glitches may occur if invalid block)
  650.         BLDRBuilderConfig.brickCommonBlock = 45; //BrickBuilder Common Block
  651.         BLDRBuilderConfig.brickRareBlock = 98; //BrickBuilder Rare Block
  652.         BLDRBuilderConfig.cobbleCommonBlock = 4; //CobbleBuilder Common Block
  653.         BLDRBuilderConfig.cobbleRareBlock = 1; //CobbleBuilder Rare Block
  654.         BLDRBuilderConfig.homeCommonBlock = 3; //Home Seeker Common Block
  655.         BLDRBuilderConfig.homeRareBlock = 35; //Home Seeker Rare Block
  656.         BLDRBuilderConfig.explorerBlock = 50; //Explorer Block
  657.         BLDRBuilderConfig.explorerMBlock = 24; //Explorer Mayor-Aid Block
  658.         BLDRBuilderConfig.treasureMBlock = 5; //Treasure Hunter Mayor-Aid Block
  659.         BLDRBuilderConfig.traderBlock = 1; //Trader Build Block
  660.         BLDRBuilderConfig.bakerBlock = 1; //Baker Build Block
  661.         BLDRBuilderConfig.sandBlock = 24; //SandBuilder Build Block
  662.        
  663.         //Misc.
  664.         BLDRBuilderConfig.buildAnywhere = false; //Determines whether builders build over other terrain
  665.         BLDRBuilderConfig.enableNames = true; //Determines whether Names appear above Builders
  666.         BLDRBuilderConfig.freeLanceStyle = 1; //determines build style
  667.  
  668.     }
  669.  
  670.     @Override
  671.     public void addRenderer(Map map)
  672.     {
  673.         map.put(BLDREntityBrickBuilder.class, new BLDRRenderBuilder(new ModelBiped(), 0.5F));
  674.         map.put(BLDREntityCobbleBuilder.class, new BLDRRenderBuilder(new ModelBiped(), 0.5F));
  675.         map.put(BLDREntityExplorer.class, new BLDRRenderBuilder(new ModelBiped(), 0.5F));
  676.         map.put(BLDREntityHomeSeeker.class, new BLDRRenderBuilder(new ModelBiped(), 0.5F));
  677.         map.put(BLDREntityTreasureHunter.class, new BLDRRenderBuilder(new ModelBiped(), 0.5F));
  678.         map.put(BLDREntityMayor.class, new BLDRRenderBuilder(new ModelBiped(), 0.5F));
  679.         map.put(BLDREntityMultiBuilder.class, new BLDRRenderBuilder(new ModelBiped(), 0.5F));
  680.         map.put(BLDREntityTrader.class, new BLDRRenderBuilder(new ModelBiped(), 0.5F));
  681.         map.put(BLDREntityBaker.class, new BLDRRenderBuilder(new ModelBiped(), 0.5F));
  682.         map.put(BLDREntitySandBuilder.class, new BLDRRenderBuilder(new ModelBiped(), 0.5F));
  683.     }
  684.  
  685.     @Override
  686.     public String getVersion()
  687.     {
  688.         return "1.8";
  689.     }
  690.  
  691.     public void ModsLoaded()
  692.     {
  693.           //If MineColony found, adapt mod accordingly
  694.         checkForMineColony();
  695.        
  696.         //If Humans+ found, adapt mod accordingly
  697.         //checkForHumansPlus();
  698.     }
  699.    
  700.     public void checkForMineColony(){
  701.         try {
  702.             Class.forName("mod_MineColony");
  703.             colonyWorker = Class.forName("EntityWorker");
  704.             mineColonyDetected = true;
  705.         } catch (Throwable e) {
  706.             mineColonyDetected = false;
  707.         }
  708.     }
  709.    
  710.    /* private void checkForHumansPlus(){
  711.         try {
  712.             Class.forName("mod_HumansPlus");
  713.             humanSettler = Class.forName("EntitySettler").asSubclass(EntityLiving.class);
  714.             humanWanderer = Class.forName("EntityWanderer").asSubclass(EntityLiving.class);
  715.             humansPlusDetected = true;
  716.         } catch (Throwable e) {
  717.             humansPlusDetected = false;
  718.         }
  719.     }*/
  720.  
  721.     //load all txt files and schematic files to singlePrints array
  722.     private void loadAllSingleBlueprints(File[] files){
  723.         //load all single blueprints
  724.         File results = new File(files[0].getParentFile().getParentFile(), "results.txt");
  725.         FileWriter output = null;
  726.         if(results.exists()) results.delete();
  727.         try {
  728.             results.createNewFile();
  729.             output = new FileWriter(results);
  730.             output.write("Results.txt file created!\n");
  731.         } catch (IOException e) {
  732.             e.printStackTrace();
  733.         }
  734.         //input each file
  735.         for(int i = 0; i < files.length; i++){
  736.             if(!files[i].isFile()) continue; //skip nonFiles
  737.             else if (files[i].getName().toLowerCase().contains(".txt")) loadBlueprint(output, files[i], 0);
  738.             else if (files[i].getName().toLowerCase().contains(".schematic")) loadSchematic(output, files[i], 0);
  739.             else continue;
  740.         }
  741.         //when complete verify success in results.txt
  742.         try {
  743.             output.write("All txt files & schematic files scanned.\n");
  744.             output.close();
  745.         } catch (IOException e1) {
  746.             e1.printStackTrace();
  747.         }
  748.        
  749.     }
  750.    
  751.     //this method loads a blueprint from a .txt file (name, then coordinates), and adds it to an array based on type
  752.     private void loadBlueprint(FileWriter results, File input, int type){
  753.         int test = 0;
  754.         BufferedReader br = null;
  755.         boolean hasName = false;
  756.         boolean inLayer = false;
  757.         String name = "";
  758.         ArrayList<ArrayList<ArrayList<Short>>> blueprintYXZ = new ArrayList<ArrayList<ArrayList<Short>>>();
  759.         ArrayList<ArrayList<Short>> blueprintXZ = new ArrayList<ArrayList<Short>>();
  760.         ArrayList<Short> blueprintZ = new ArrayList<Short>();
  761.         try {
  762.             test = -1;
  763.             br = new BufferedReader(new FileReader(input));
  764.             String thisLine;
  765.             test = 0;
  766.             thisLine = br.readLine();
  767.             while(thisLine != null){
  768.                 test++;
  769.                 //skip all lines beginning with "//"
  770.                 if(thisLine.startsWith("//")){
  771.                     thisLine = br.readLine();
  772.                     continue;
  773.                 }
  774.  
  775.                 else if(thisLine.startsWith("##")){
  776.                     String text = thisLine.substring(2).toLowerCase();
  777.                     //if line begins with ##, and it is first instance of this, set text after that to name
  778.                     if(!hasName){
  779.                         hasName = true;
  780.                         name = text;
  781.                     }
  782.                     //if line begins with ##Layer, on next line start loading coordinates
  783.                     else if(!inLayer && text.startsWith("layer")){
  784.                         inLayer = true;
  785.                     }
  786.                     //if line begins with  ##End Layer, stop loading coordinates for this layer, else continue
  787.                     else if(inLayer && text.startsWith("end layer")){
  788.                         inLayer = false;
  789.                         blueprintYXZ.add(blueprintXZ);
  790.                         blueprintXZ = new ArrayList<ArrayList<Short>>();
  791.                     }
  792.                     else{
  793.                         throw new Exception();
  794.                     }
  795.                     thisLine = br.readLine();
  796.                     continue;
  797.                 }
  798.                 //if line begins with neither of above, check if in layer, trim spaces at end of line, and add numericals to list, else error
  799.                 //if text split on spaces does not contain all numericals(Short), then error
  800.                 else if(inLayer){
  801.                     String nums[] = thisLine.trim().split(" ");
  802.                     for(int i = 0; i < nums.length; i++){
  803.                         String dat[] = nums[i].split(":");
  804.                         short id = (short) (dat.length > 1 ? Short.valueOf(dat[0]) + ((Short.valueOf(dat[1]) & 15) << 10) : Short.valueOf(dat[0]));
  805.                         blueprintZ.add(id);
  806.                     }
  807.  
  808.                     blueprintXZ.add(blueprintZ);
  809.                     blueprintZ = new ArrayList<Short>();
  810.                     thisLine = br.readLine();
  811.                 }
  812.                 //If any invalid input or improper structure, output failure to results file in super Directory
  813.                 else{
  814.                     throw new Exception();
  815.                 }
  816.             }
  817.             test = -5;
  818.             br.close();
  819.             //If file ends and it succeeds, add new list<list<list<short>>>> to proper list(based on type) and output success to results file
  820.             try {
  821.                 if(type == 0){
  822.                     BLDRBlueprints.singlePrintNames.add(name);
  823.                     BLDRBlueprints.singlePrints.add(blueprintYXZ);
  824.                     //check Blueprints for builder-specific blueprints
  825.                     assignSpecialPrint(name.toLowerCase(), BLDRBlueprints.singlePrintNames.size() - 1, results);
  826.                 }
  827.                 results.write(input.getName().concat(" was added!\r"));
  828.             } catch (IOException e1) {
  829.                 e1.printStackTrace();
  830.             }
  831.         } catch (Exception e) {
  832.             try {
  833.                 if(test > 0)
  834.                     results.write(input.getName().concat(" was not read properly. Line ").concat(String.valueOf(test)).concat("\r"));
  835.                 else
  836.                     results.write(input.getName().concat(" was not read properly. Failure Case ").concat(String.valueOf(test)).concat("\r"));
  837.             } catch (IOException e1) {
  838.                 e1.printStackTrace();
  839.             }
  840.         }
  841.        
  842.     }
  843.    
  844.     //this method loads a blueprint from a .schematic file (coordinates only; name = filename(replace all _ with space)), and adds it to an array based on type
  845.     private void loadSchematic(FileWriter results, File input, int type){
  846.         int test = 0;
  847.         String name = "";
  848.         ArrayList<ArrayList<ArrayList<Short>>> blueprintYXZ = new ArrayList<ArrayList<ArrayList<Short>>>();
  849.         ArrayList<ArrayList<Short>> blueprintXZ = new ArrayList<ArrayList<Short>>();
  850.         ArrayList<Short> blueprintZ = new ArrayList<Short>();
  851.        try{
  852.             test = -1;
  853.             FileInputStream fileinputstream = new FileInputStream(input);
  854.             test = -2;
  855.             NBTTagCompound nbttagcompound = CompressedStreamTools.readCompressed(fileinputstream);
  856.             test = -3;
  857.             if(nbttagcompound.hasKey("Schematic"))
  858.                 nbttagcompound = nbttagcompound.getCompoundTag("Schematic");
  859.             //make name same as file name without extension
  860.             test = -4;
  861.             String fileName = input.getName();
  862.             test = -5;
  863.             fileName = fileName.replace("_", " ");
  864.             test = -6;
  865.             name = fileName.substring(0, fileName.length() - 10);
  866.             test = -7;
  867.             //get tag list of block array and measurements
  868.             byte blockids[] = nbttagcompound.getByteArray("Blocks");
  869.             test = -8;
  870.             byte blockdata[] = nbttagcompound.getByteArray("Data");
  871.             test = -81;
  872.             short width = nbttagcompound.getShort("Width");
  873.             test = -9;
  874.             short length = nbttagcompound.getShort("Length");
  875.             test = -10;
  876.             short height = nbttagcompound.getShort("Height");
  877.             test = 0;
  878.             int bSize = length * width * height;
  879.             //read data from byte array into arraylists
  880.             for(short y = 0; y < height; y++){
  881.                 for(short z = 0; z < length; z++){
  882.                     for(short x = 0; x < width; x++){
  883.                         test++;
  884.                         blueprintZ.add((short) (blockids[x + (y * length + z) * width] + ((blockdata[x + (y * length + z) * width] & 15) << 10)));
  885.                     }
  886.                     blueprintXZ.add(blueprintZ);
  887.                     blueprintZ = new ArrayList<Short>();
  888.                 }
  889.                 blueprintYXZ.add(blueprintXZ);
  890.                 blueprintXZ = new ArrayList<ArrayList<Short>>();
  891.             }
  892.             test = -11;
  893.           //If file ends and it succeeds, add new list<list<list<short>>>> to proper list(based on type) and output success to results file
  894.             try {
  895.                 if(type == 0){
  896.                     BLDRBlueprints.singlePrintNames.add(name);
  897.                     BLDRBlueprints.singlePrints.add(blueprintYXZ);
  898.                 }
  899.                 results.write(input.getName().concat(" was added! ").concat(String.valueOf(bSize)).concat(" Blocks!\r"));
  900.             } catch (IOException e1) {
  901.                 e1.printStackTrace();
  902.             }
  903.            
  904.        }catch(Exception e){
  905.           try {
  906.              if(test < 0)
  907.                 results.write(input.getName().concat(" was not formatted correctly. Fail Case ").concat(String.valueOf(test)).concat("\r"));
  908.              else
  909.                 results.write(input.getName().concat(" did not contain a properly formatted byte array. Failed at byte ").concat(String.valueOf(test)).concat("\r"));
  910.             } catch (IOException e1) {
  911.                 e1.printStackTrace();
  912.             }
  913.        }
  914.     }
  915.    
  916.     //finds and assigns index of specific blueprints used by some builders
  917.     private void assignSpecialPrint(String txt, int index, FileWriter results){
  918.         boolean success = BLDRBlueprints.setSpecialPrint(txt,index);
  919.        
  920.         if(success == false) return;
  921.        
  922.         try {
  923.              results.write(txt.concat(" was assigned index value ").concat(String.valueOf(index)).concat(".\r"));
  924.             } catch (IOException e1) {
  925.                 e1.printStackTrace();
  926.             }
  927.     }
  928.     //Static Methods
  929.    
  930.     /**
  931.      *  Name: dropChestItem()
  932.      * Parameters: EntityBuilder [builder who will drop an item]
  933.      * Spawns an item near the specified builder; The item spawned is one of the builder's trade chest items
  934.      * Returns true if the item successfully joined the world; false otherwise
  935.      */
  936.     public static boolean dropChestItem(BLDREntityBuilder eB){
  937.         ItemStack itemstack = eB.getChestItem();
  938.         EntityItem entityitem = new EntityItem(eB.worldObj, eB.posX, eB.posY + 0.2F, eB.posZ, itemstack);
  939.         entityitem.delayBeforeCanPickup = 10;
  940.         entityitem.age = 4800; //set to despawn after a minute
  941.         return eB.worldObj.spawnEntityInWorld(entityitem);
  942.     }
  943.    
  944.     //makes a living entity dodge a entity
  945.     public static boolean dodgeAttack(Entity entityToDodge, EntityLiving dodger, int i){
  946.         double d = entityToDodge.posX - dodger.posX;
  947.         double d1;
  948.         for(d1 = entityToDodge.posZ - dodger.posZ; d * d + d1 * d1 < 0.0001D; d1 = (Math.random() - Math.random()) * 0.01D)
  949.         {
  950.             d = (Math.random() - Math.random()) * 0.01D;
  951.         }
  952.         dodger.knockBack(entityToDodge, i, -d1, d);
  953.         if(dodger.motionY > 0.3D)
  954.             dodger.motionY = 0.3D;
  955.         return true;
  956.     }
  957.    
  958.     //Spawns particles at an entity
  959.     //Available particles: bubble, smoke, note, portal, explode, flame, lava, splash, largesmoke, reddust, snowballpoof, slime
  960.     public static boolean spawnParticlesAtEntity(Entity entity, String particle, int numParticles){
  961.         Random rand = new Random();
  962.         for(int j = 0; j < numParticles; j++)
  963.         {
  964.             double d = rand.nextGaussian() * 0.02D;
  965.             double d1 = rand.nextGaussian() * 0.02D;
  966.             double d2 = rand.nextGaussian() * 0.02D;
  967.             entity.worldObj.spawnParticle(particle, (entity.posX + (double)(rand.nextFloat() * entity.width * 2.0F)) - (double)entity.width, entity.posY + (double)(rand.nextFloat() * entity.height), (entity.posZ + (double)(rand.nextFloat() * entity.width * 2.0F)) - (double)entity.width, d, d1, d2);
  968.         }
  969.         return true;
  970.     }
  971.    
  972.     //mineColony variables
  973.     public static boolean mineColonyDetected; //true if mineColony detected
  974.     public static Class colonyWorker; //mineColony worker, including Lumberjack, Miner, etc.
  975.    
  976.     //Humans+ variables
  977.     /*public static boolean humansPlusDetected; //true if Humans+ detected
  978.     public static Class humanSettler; //settlers
  979.     public static Class humanWanderer; //wanderers*/
  980.    
  981.     public static Minecraft minecraft_b;
  982.     //Minecraft.isWorldLoaded
  983.     //Minecraft.currentScreen
  984.     //Minecraft.objectMouseOver.blockX,Y,Z
  985.    
  986.    
  987.     public static boolean signEdit;
  988.     public static TileEntitySign sign;
  989.     public static boolean saveSignList;
  990.     public static boolean loadSignList;
  991.     public static World world;
  992.     public static List<BLDRBuilderSigns> signsList;
  993.     public static boolean folderDetected;
  994.     public static List<BLDREntityBuilder> builderList;
  995.     public static int builderCount;
  996.     public static final Class builderTypes[] = {
  997.         BLDREntityBaker.class, BLDREntityTrader.class, BLDREntityBrickBuilder.class, BLDREntityCobbleBuilder.class,
  998.         BLDREntitySandBuilder.class, BLDREntityMultiBuilder.class, BLDREntityHomeSeeker.class, BLDREntityMayor.class,
  999.         BLDREntityExplorer.class, BLDREntityTreasureHunter.class
  1000.     };
  1001.    
  1002.     public static ArrayList<BLDREntityBuilder> assistants;
  1003.  
  1004.     /**
  1005.      * This is true when the player's cursor is actually over a block; false otherwise
  1006.      */
  1007.     protected boolean blockT;
  1008.     /**
  1009.      * This is the entity that the player's cursor is currently on; null if the player's cursor is not on an entity.
  1010.      */
  1011.     protected Entity entityTarget;
  1012.     /**
  1013.      * Last valid block that player's cursor has been over.  
  1014.      * Used by some items for determining if the block currently being destroyed/farmed is valid for
  1015.      * giving additional rewards.
  1016.      */
  1017.     protected ChunkCoordinates coords;
  1018.     /**
  1019.      * If true, then coords is to be used; otherwise, coords is to be ignored
  1020.      */
  1021.     protected boolean coordsT;
  1022.     /**
  1023.      * misc. number
  1024.      * used differently depending on the item, but primarily a timer.
  1025.      */
  1026. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement