Selaa lähdekoodia

Brainfarts being Brainfarts... To and from should be the right way round

LH 3 vuotta sitten
vanhempi
commit
526497bbe0

+ 81 - 38
LogBlockHeatMapper/src/main/java/de/nplusc/izc/logblockheatmapper/LogBlockHeatmapperRegionTrimmer.java

@@ -111,7 +111,8 @@ public class LogBlockHeatmapperRegionTrimmer
             "minecraft:lime_shulker_box",
             "minecraft:green_shulker_box",
             "minecraft:blue_shulker_box",
-            "minecraft:hopper"
+            "minecraft:hopper",
+            "minecraft:chest"
     );
 
       //x  y
@@ -152,6 +153,9 @@ public class LogBlockHeatmapperRegionTrimmer
     
     static final Color coreEdge = new Color(255, 0, 0);
 
+
+    static int fuckyou = 0;
+
     private static void setRegion(int x,int y, int s)
     {
         int rx = (int)Math.floor((x)/512.0f);
@@ -236,6 +240,7 @@ public class LogBlockHeatmapperRegionTrimmer
         }
         
         BufferedReader br = new BufferedReader(new FileReader(args[0]));
+        PrintStream lmaa = new PrintStream(new FileOutputStream("fuckyouandeatshit.txt"));
         br.lines().forEach((xx)->
         {
             
@@ -247,36 +252,45 @@ public class LogBlockHeatmapperRegionTrimmer
             String[] xes = xx.split("\\t");
             int l = Integer.parseInt(xes[0]);
             boolean register=false;
-            String from = xes[2].intern();
-            String to = xes[3].intern();
+            String to = xes[2].intern();
+            String from = xes[3].intern(); //richtigrum, verfickt und zugenäht
             int x= Integer.parseInt(xes[4])+radius,y= Integer.parseInt(xes[6])+radius;
 
             int z = Integer.parseInt(xes[5]);
             if(blocktypes.contains(from)||blocktypes.contains(to))
             {
-                if(blocktypes.contains(from))
+                if(from!=to) // yes, this works since i interned the strings beforehand :P
                 {
-                    CoordHolder location = new CoordHolder(x,y,z,from);
-                    if(!workbenchCalculations.containsKey(location))
+                    fuckyou++;
+                    lmaa.println(xx);
+                    if(blocktypes.contains(from))
                     {
-                        workbenchCalculations.put(location,-1);
+                        CoordHolder location = new CoordHolder(x,y,z,from);
+                        if(!workbenchCalculations.containsKey(location))
+                        {
+                            workbenchCalculations.put(location,-1);
+                        }
+                        else
+                        {
+                            workbenchCalculations.put(location,workbenchCalculations.get(location)-1);
+                        }
                     }
-                    else
+                    if(blocktypes.contains(to))
                     {
-                        workbenchCalculations.put(location,workbenchCalculations.get(location)-1);
+                        CoordHolder location = new CoordHolder(x,y,z,to);
+                        if(!workbenchCalculations.containsKey(location))
+                        {
+                            workbenchCalculations.put(location,1);
+                        }
+                        else
+                        {
+                            workbenchCalculations.put(location,workbenchCalculations.get(location)+1);
+                        }
                     }
                 }
                 else
                 {
-                    CoordHolder location = new CoordHolder(x,y,z,to);
-                    if(!workbenchCalculations.containsKey(location))
-                    {
-                        workbenchCalculations.put(location,1);
-                    }
-                    else
-                    {
-                        workbenchCalculations.put(location,workbenchCalculations.get(location)+1);
-                    }
+                    //System.out.print("Skipped Transaction due to from and to being equal");
                 }
 
             }
@@ -315,15 +329,28 @@ public class LogBlockHeatmapperRegionTrimmer
                 System.out.print(l+"changes so far\r");
             }
         });
+        System.out.println("\n");
+        System.out.println(fuckyou);
         System.out.println("\nDatabase crunched to 100%\n");
 
         System.out.print("\nCalculating Workbenches("+workbenchCalculations.size()+") \n");
-
+        lmaa.close();
         workbenchCalculations.forEach((c,i) ->
         {
             if(i>0)
             {
-                setRegion(c.x-radius,c.y-radius,10000); // force keep
+                System.out.println("workbench at"+c.x+"|"+c.y);
+                if(c.x<0||c.y<0||c.x>=dataField.length||c.y>=dataField.length)
+                {
+                    return;
+                }
+                System.out.println("workbench kept at"+c.x+"|"+c.y+"| cnt = "+i);
+                setRegion(c.x-radius,c.y-radius,3*treshold); // force keep
+                dataField[c.y][c.x]=BlockState.WORKBENCH_FORCED.ordinal();
+            }
+            if(i<-1)
+            {
+                System.out.println("DAFUQ at"+c.x+"|"+c.y+"| as "+i);
             }
         });
 
@@ -337,15 +364,19 @@ public class LogBlockHeatmapperRegionTrimmer
                 System.out.println("Processing r."+(i)+"."+(j)+".mca; ("+i+"/"+regionBase+"|"+j+"/"+regionBase);
                 if(current<treshold)
                 {
-                    keepRegions.put(("r."+(i)+"."+(j)+".mca"),RegionState.REMOVE);
+                    if(!(keepRegions.getOrDefault(("r."+(i)+"."+(j)+".mca"),RegionState.REMOVE)==RegionState.CORE))
+                    {
+                        keepRegions.put(("r."+(i)+"."+(j)+".mca"),RegionState.REMOVE);
+                    }
+
                     if(current>0) // no activity inside so no need to search for activity spots
                     {
                         for(int pi = 0;pi<512;pi++)
                         {
                             for(int pj = 0;pj<512;pj++)
                             {
-                                int kx = i*512+pi+radius;
-                                int ky = j*512+pj+radius;
+                                int kx = i*512+pi+radius+1;
+                                int ky = j*512+pj+radius+1;
                                 if(kx<0||ky<0||kx>=dataField.length||ky>=dataField.length)
                                 {
                                     continue; // coordinate not valid. can't crunch
@@ -378,7 +409,7 @@ public class LogBlockHeatmapperRegionTrimmer
 
                             if(k==BlockState.ACTIVITY)
                             {
-                                if(pi<30&&pj<30)
+                                if(pi<30&&pj<31)
                                 {
                                     keepRegions.put(("r."+(i-1)+"."+(j-1)+".mca"),RegionState.KEEP);
                                 }
@@ -390,7 +421,7 @@ public class LogBlockHeatmapperRegionTrimmer
                                 {
                                     keepRegions.put(("r."+(i)+"."+(j-1)+".mca"),RegionState.KEEP);
                                 }
-                                int max = 512-30;
+                                int max = 512-31;
 
                                 if(pi>max&&pj>max)
                                 {
@@ -406,11 +437,11 @@ public class LogBlockHeatmapperRegionTrimmer
                                 }
 
                                 //propagating buffers
-                                int kxmin = Math.max(0,kx-30);
-                                int kymin = Math.max(0,ky-30);
+                                int kxmin = Math.max(0,kx-31);
+                                int kymin = Math.max(0,ky-31);
 
-                                int kxmax = Math.min(dataField.length,kx+30);
-                                int kymax = Math.min(dataField.length,ky+30);
+                                int kxmax = Math.min(dataField.length,kx+31);
+                                int kymax = Math.min(dataField.length,ky+31);
 
                                 for(int ki = kxmin;ki<kxmax;ki++)
                                 {
@@ -427,19 +458,19 @@ public class LogBlockHeatmapperRegionTrimmer
 
                             if(k==BlockState.WORKBENCH_FORCED)
                             {
-                                if(pi<50&&pj<50)
+                                if(pi<50&&pj<51)
                                 {
                                     keepRegions.put(("r."+(i-1)+"."+(j-1)+".mca"),RegionState.KEEP);
                                 }
-                                if(pi<50)
+                                if(pi<51)
                                 {
                                     keepRegions.put(("r."+(i-1)+"."+(j)+".mca"),RegionState.KEEP);
                                 }
-                                if (pj<50)
+                                if (pj<51)
                                 {
                                     keepRegions.put(("r."+(i)+"."+(j-1)+".mca"),RegionState.KEEP);
                                 }
-                                int max = 512-50;
+                                int max = 512-51;
 
                                 if(pi>max&&pj>max)
                                 {
@@ -455,11 +486,11 @@ public class LogBlockHeatmapperRegionTrimmer
                                 }
 
                                 //propagating buffers
-                                int kxmin = Math.max(0,kx-50);
-                                int kymin = Math.max(0,ky-50);
+                                int kxmin = Math.max(0,kx-51);
+                                int kymin = Math.max(0,ky-51);
 
-                                int kxmax = Math.min(dataField.length,kx+50);
-                                int kymax = Math.min(dataField.length,ky+50);
+                                int kxmax = Math.min(dataField.length,kx+51);
+                                int kymax = Math.min(dataField.length,ky+51);
 
                                 for(int ki = kxmin;ki<kxmax;ki++)
                                 {
@@ -627,4 +658,16 @@ public class LogBlockHeatmapperRegionTrimmer
         AND player.UUID NOT LIKE 'l%'
         INTO OUTFILE 'C:/lmaa/crunchme/survival2-oct-novirt.csv'
         ;
-*/
+*/
+
+
+
+/*
+SELECT blocks.id, blocks.id, materials.name, materials2.name, blocks.x,blocks.y, blocks.z FROM `lb-players` as player, `lb-surv-blocks` as blocks, `lb-materials` as materials, `lb-materials` as materials2
+        where player.playerid = blocks.playerid
+        AND player.UUID NOT LIKE 'l%'
+        and blocks.type = materials.id
+        and blocks.replaced = materials2.id
+        INTO OUTFILE '/tmp/crunchy.csv';
+
+* */