G2A Many GEOs
SHARE
TWEET

Untitled

Anon5703 Dec 1st, 2015 90 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.jase2z.WUmod;
  2.  
  3. import com.wurmonline.server.items.ItemTemplate;
  4. import com.wurmonline.server.items.ItemTemplateFactory;
  5.  
  6. import org.gotti.wurmunlimited.modloader.ReflectionUtil;
  7. import org.gotti.wurmunlimited.modloader.interfaces.Initable;
  8. import org.gotti.wurmunlimited.modloader.interfaces.ServerStartedListener;
  9. import org.gotti.wurmunlimited.modloader.interfaces.WurmMod;
  10.  
  11. import java.lang.reflect.Field;
  12. import java.lang.Math;
  13. import java.util.*;
  14.  
  15.  
  16. public class BigContainersBAEAMod implements WurmMod, Initable, ServerStartedListener {
  17.     public static int LARGE_CART;
  18.     public static int FORGE;
  19.     public static int JEWELRY_BOWL;
  20.     public static int OVEN;
  21.     public static int ROWING_BOAT;
  22.     public static int SMALL_CART;
  23.     public static int STONE_ALTAR;
  24.     public static int BSB;
  25.     public static int FSB;
  26.     public static int TRASH_HEAP;
  27.     public static int PELT;
  28.     public static int BK_MUSHROOM;
  29.     public static int GN_MUSHROOM;
  30.     public static int YL_MUSHROOM;
  31.     public static int BL_MUSHROOM;
  32.     public static int BN_MUSHROOM;
  33.     public static int RD_MUSHROOM;
  34.     public static int FELLED_TREE;
  35.     public static int INK_SAC;
  36.     public static int COCHINEAL;
  37.     public static int SADDLE;
  38.     public static int STONE_KEYSTONE;
  39.     public static int MARBLE_KEYSTONE;
  40.     public static int BASS;
  41.     public static int CARP;
  42.     public static int CATFISH;
  43.     public static int SNOOK;
  44.     public static int HERRING;
  45.     public static int PIKE;
  46.     public static int ROACH;
  47.     public static int TROUT;
  48.     public static int PERCH;
  49.     public static int MARLIN;
  50.     public static int BLUE_SHARK;
  51.     public static int WHITE_SHARK;
  52.     public static int OCTOPUS;
  53.     public static int SAILFISH;
  54.     public static int DORADO;
  55.     public static int TUNA;
  56.     public static int F_FISHING_LINE;
  57.     public static int WOAD;
  58.  
  59.  
  60.  
  61.  
  62.     static {
  63.         BigContainersBAEAMod.LARGE_CART = 539;
  64.         BigContainersBAEAMod.FORGE = 180;
  65.         BigContainersBAEAMod.JEWELRY_BOWL = 326;
  66.         BigContainersBAEAMod.OVEN = 178;
  67.         BigContainersBAEAMod.ROWING_BOAT = 490;
  68.         BigContainersBAEAMod.SMALL_CART = 186;
  69.         BigContainersBAEAMod.STONE_ALTAR = 323;
  70.         BigContainersBAEAMod.BSB = 662;
  71.         BigContainersBAEAMod.FSB = 661;
  72.         BigContainersBAEAMod.TRASH_HEAP = 670;
  73.         BigContainersBAEAMod.PELT = 313;
  74.         BigContainersBAEAMod.BK_MUSHROOM = 247;
  75.         BigContainersBAEAMod.GN_MUSHROOM = 246;
  76.         BigContainersBAEAMod.YL_MUSHROOM = 249;
  77.         BigContainersBAEAMod.BL_MUSHROOM = 250;
  78.         BigContainersBAEAMod.BN_MUSHROOM = 248;
  79.         BigContainersBAEAMod.RD_MUSHROOM = 251;
  80.         BigContainersBAEAMod.FELLED_TREE = 385;
  81.         BigContainersBAEAMod.INK_SAC = 752;
  82.         BigContainersBAEAMod.COCHINEAL = 439;
  83.         BigContainersBAEAMod.SADDLE = 621;
  84.         BigContainersBAEAMod.STONE_KEYSTONE = 905;
  85.         BigContainersBAEAMod.MARBLE_KEYSTONE = 906;
  86.         BigContainersBAEAMod.BASS = 158;
  87.         BigContainersBAEAMod.CARP = 164;
  88.         BigContainersBAEAMod.CATFISH = 160;
  89.         BigContainersBAEAMod.SNOOK = 161;
  90.         BigContainersBAEAMod.HERRING = 159;
  91.         BigContainersBAEAMod.PIKE = 157;
  92.         BigContainersBAEAMod.ROACH = 162;
  93.         BigContainersBAEAMod.TROUT = 165;
  94.         BigContainersBAEAMod.PERCH = 163;
  95.         BigContainersBAEAMod.MARLIN = 569;
  96.         BigContainersBAEAMod.BLUE_SHARK = 570;
  97.         BigContainersBAEAMod.WHITE_SHARK = 571;
  98.         BigContainersBAEAMod.OCTOPUS = 572;
  99.         BigContainersBAEAMod.SAILFISH = 573;
  100.         BigContainersBAEAMod.DORADO = 574;
  101.         BigContainersBAEAMod.TUNA = 575;
  102.         BigContainersBAEAMod.F_FISHING_LINE = 150;
  103.         BigContainersBAEAMod.WOAD = 440;
  104.     }
  105.  
  106.     public void onServerStarted() {
  107.  
  108.         // ********************** Get needed fields **********************
  109.         Map<Integer, ItemTemplate> templates = null;
  110.         Field fieldOnePerTile = null;
  111.         Field fieldUsesSpecifiedContainerSizes = null;
  112.         Field fieldIsTransportable = null;
  113.         Field fieldCentimetersX = null;
  114.         Field fieldCentimetersY = null;
  115.         Field fieldCentimetersZ = null;
  116.         Field fieldVolume = null;
  117.         Field fieldContainerCentimetersX = null;
  118.         Field fieldContainerCentimetersY = null;
  119.         Field fieldContainerCentimetersZ = null;
  120.         Field fieldContainerVolume = null;
  121.         Field fieldWeight = null;
  122.         Field fieldBulk = null;
  123.         Field fieldCombine = null;
  124.         Field fieldOutsideonly = null;
  125.         Field fieldInsideOnly = null;
  126.         try {
  127.             templates = ReflectionUtil.getPrivateField(
  128.                     ItemTemplateFactory.class, ReflectionUtil.getField(ItemTemplateFactory.class, "templates"));
  129.             fieldOnePerTile = ReflectionUtil.getField(ItemTemplate.class, "onePerTile");
  130.             fieldUsesSpecifiedContainerSizes = ReflectionUtil.getField(ItemTemplate.class, "usesSpecifiedContainerSizes");
  131.             fieldIsTransportable = ReflectionUtil.getField(ItemTemplate.class, "isTransportable");
  132.             fieldCentimetersX = ReflectionUtil.getField(ItemTemplate.class, "centimetersX");
  133.             fieldCentimetersY = ReflectionUtil.getField(ItemTemplate.class, "centimetersY");
  134.             fieldCentimetersZ = ReflectionUtil.getField(ItemTemplate.class, "centimetersZ");
  135.             fieldVolume = ReflectionUtil.getField(ItemTemplate.class, "volume");
  136.             fieldContainerCentimetersX = ReflectionUtil.getField(ItemTemplate.class, "containerCentimetersX");
  137.             fieldContainerCentimetersY = ReflectionUtil.getField(ItemTemplate.class, "containerCentimetersY");
  138.             fieldContainerCentimetersZ = ReflectionUtil.getField(ItemTemplate.class, "containerCentimetersZ");
  139.             fieldContainerVolume = ReflectionUtil.getField(ItemTemplate.class, "containerVolume");
  140.             fieldWeight = ReflectionUtil.getField(ItemTemplate.class, "weight");
  141.             fieldBulk = ReflectionUtil.getField(ItemTemplate.class, "bulk");
  142.             fieldCombine = ReflectionUtil.getField(ItemTemplate.class, "combine");
  143.             fieldOutsideonly = ReflectionUtil.getField(ItemTemplate.class, "outsideonly");
  144.             fieldInsideOnly = ReflectionUtil.getField(ItemTemplate.class, "insideOnly");
  145.         } catch (IllegalAccessException | NoSuchFieldException | NullPointerException e){
  146.             e.printStackTrace();
  147.         }
  148.         assert fieldOnePerTile != null;
  149.         assert fieldUsesSpecifiedContainerSizes != null;
  150.         assert fieldIsTransportable != null;
  151.         assert fieldCentimetersX != null;
  152.         assert fieldCentimetersY != null;
  153.         assert fieldCentimetersZ != null;
  154.         assert fieldVolume != null;
  155.         assert fieldContainerCentimetersX != null;
  156.         assert fieldContainerCentimetersY != null;
  157.         assert fieldContainerCentimetersZ != null;
  158.         assert fieldContainerVolume != null;
  159.         assert fieldWeight != null;
  160.         assert fieldBulk != null;
  161.         assert fieldCombine != null;
  162.         assert fieldOutsideonly != null;
  163.         assert fieldInsideOnly != null;
  164.  
  165.  
  166.         // ******************** start iteration through all the templates******************************
  167.         for ( ItemTemplate template : templates.values()) {
  168.             // *******************Set internal sizes big for select templates.*************************
  169.             Integer a = template.getTemplateId();
  170.             if (a == LARGE_CART || a == FORGE || a == JEWELRY_BOWL || a == OVEN || a == ROWING_BOAT ||
  171.                     a == SMALL_CART || a == STONE_ALTAR || a == BSB || a == FSB || a == TRASH_HEAP) {
  172.                 if (!template.usesSpecifiedContainerSizes()) {
  173.                     try {
  174.                         ReflectionUtil.setPrivateField(template, fieldUsesSpecifiedContainerSizes, Boolean.TRUE);
  175.                     } catch (IllegalAccessException e) {
  176.                         e.printStackTrace();
  177.                     }
  178.                 }
  179.                 template.setContainerSize(1200, 1200, 1200);
  180.             }
  181.             // *******************Make all internal sizes uniform****************
  182.             if (template.usesSpecifiedContainerSizes()){
  183.                 try {
  184.                     int contX = ReflectionUtil.getPrivateField(template, fieldContainerCentimetersX);
  185.                     int contY = ReflectionUtil.getPrivateField(template, fieldContainerCentimetersY);
  186.                     int contZ = ReflectionUtil.getPrivateField(template, fieldContainerCentimetersZ);
  187.                     int uniform = Math.max(new Double(Math.ceil(Math.cbrt(contX * contY * contZ))).intValue(), 1);
  188.                     ReflectionUtil.setPrivateField(template, fieldContainerCentimetersX, uniform);
  189.                     ReflectionUtil.setPrivateField(template, fieldContainerCentimetersY, uniform);
  190.                     ReflectionUtil.setPrivateField(template, fieldContainerCentimetersZ, uniform);
  191.                     ReflectionUtil.setPrivateField(template, fieldContainerVolume, uniform * uniform * uniform);
  192.                 }catch (IllegalAccessException e) {
  193.                     e.printStackTrace();
  194.                 }
  195.             }
  196.             //*********Remove one per tile restriction.*****************
  197.             Boolean onePerTile;
  198.             try {
  199.                 onePerTile = ReflectionUtil.getPrivateField(template, fieldOnePerTile);
  200.                 if (onePerTile) {
  201.                     ReflectionUtil.setPrivateField(template, fieldOnePerTile, Boolean.FALSE);
  202.                 }
  203.             } catch (IllegalAccessException e) {
  204.                 e.printStackTrace();
  205.             }
  206.             //***************Add Transportable flag to select templates**********************
  207.             if (a == STONE_ALTAR || a == ROWING_BOAT || a == TRASH_HEAP) {
  208.                 if (!template.isTransportable()){
  209.                     try {
  210.                         ReflectionUtil.setPrivateField(template, fieldIsTransportable, Boolean.TRUE);
  211.                     } catch (IllegalAccessException e){
  212.                         e.printStackTrace();
  213.                     }
  214.                 }
  215.             }
  216.             //*****************Make external dimensions uniform**********************
  217.             try {
  218.                 int sizeX = ReflectionUtil.getPrivateField(template, fieldCentimetersX);
  219.                 int sizeY = ReflectionUtil.getPrivateField(template, fieldCentimetersY);
  220.                 int sizeZ = ReflectionUtil.getPrivateField(template, fieldCentimetersZ);
  221.                 int uniform = Math.max(new Double(Math.floor(Math.cbrt(sizeX * sizeY * sizeZ))).intValue(), 1);
  222.                 ReflectionUtil.setPrivateField(template, fieldCentimetersX, uniform);
  223.                 ReflectionUtil.setPrivateField(template, fieldCentimetersY, uniform);
  224.                 ReflectionUtil.setPrivateField(template, fieldCentimetersZ, uniform);
  225.                 ReflectionUtil.setPrivateField(template, fieldVolume, uniform * uniform * uniform );
  226.             } catch (IllegalAccessException e) {
  227.                 e.printStackTrace();
  228.             }
  229.             //*****************resize weight for select templates**********************
  230.             if (a == PELT || a == BK_MUSHROOM || a == GN_MUSHROOM || a == YL_MUSHROOM || a == BL_MUSHROOM ||
  231.                     a == BN_MUSHROOM || a == RD_MUSHROOM) {
  232.                 int sizeX = 1;
  233.                 int sizeY = 1;
  234.                 int sizeZ = 1;
  235.                 int weight = 10;
  236.                 if (a == PELT) {
  237.                     sizeX = 10;
  238.                     sizeY = 10;
  239.                     sizeZ = 10;
  240.                     weight = 100;
  241.                 }
  242.                 if (a == BK_MUSHROOM) {
  243.                     sizeX = 2;
  244.                     sizeY = 2;
  245.                     sizeZ = 2;
  246.                     weight = 10;
  247.                 }
  248.                 if (a == GN_MUSHROOM) {
  249.                     sizeX = 2;
  250.                     sizeY = 2;
  251.                     sizeZ = 2;
  252.                     weight = 10;
  253.                 }
  254.                 if (a == YL_MUSHROOM) {
  255.                     sizeX = 10;
  256.                     sizeY = 10;
  257.                     sizeZ = 10;
  258.                     weight = 1000;
  259.                 }
  260.                 if (a == BL_MUSHROOM) {
  261.                     sizeX = 10;
  262.                     sizeY = 10;
  263.                     sizeZ = 10;
  264.                     weight = 1000;
  265.                 }
  266.                 if (a == BN_MUSHROOM) {
  267.                     sizeX = 10;
  268.                     sizeY = 10;
  269.                     sizeZ = 10;
  270.                     weight = 1000;
  271.                 }
  272.                 if (a == RD_MUSHROOM) {
  273.                     sizeX = 10;
  274.                     sizeY = 10;
  275.                     sizeZ = 10;
  276.                     weight = 1000;
  277.                 }
  278.                 try {
  279.                     ReflectionUtil.setPrivateField(template, fieldCentimetersX, sizeX);
  280.                     ReflectionUtil.setPrivateField(template, fieldCentimetersY, sizeY);
  281.                     ReflectionUtil.setPrivateField(template, fieldCentimetersZ, sizeZ);
  282.                     ReflectionUtil.setPrivateField(template, fieldWeight, weight);
  283.                 } catch (IllegalAccessException e) {
  284.                     e.printStackTrace();
  285.                 }
  286.             }
  287.             //****************add bulk flag to select templates***********************
  288.             if (a == FELLED_TREE || a == PELT || a == SADDLE || a == STONE_KEYSTONE || a == MARBLE_KEYSTONE ||
  289.                     a == BASS || a == CARP || a == CATFISH || a == SNOOK || a == HERRING || a == PIKE || a == ROACH ||
  290.                     a == TROUT || a == PERCH || a == MARLIN || a == BLUE_SHARK || a == WHITE_SHARK || a == OCTOPUS ||
  291.                     a == SAILFISH || a == DORADO || a == TUNA || a == BK_MUSHROOM || a == GN_MUSHROOM ||
  292.                     a == YL_MUSHROOM || a == BL_MUSHROOM || a == BN_MUSHROOM || a == RD_MUSHROOM || a == F_FISHING_LINE){
  293.                 try {
  294.                     ReflectionUtil.setPrivateField(template, fieldBulk, Boolean.TRUE);
  295.                 } catch (IllegalAccessException e) {
  296.                     e.printStackTrace();
  297.                 }
  298.             }
  299.             //***************add combine flags to select templates*********************
  300.             if (a == COCHINEAL || a == WOAD){
  301.                 try {
  302.                     ReflectionUtil.setPrivateField(template, fieldCombine, Boolean.TRUE);
  303.                 }catch (IllegalAccessException e) {
  304.                     e.printStackTrace();
  305.                 }
  306.             }
  307.             //*****************remove outside and inside only flags from all**********************
  308.             Boolean insideOnly;
  309.             try {
  310.                 insideOnly = ReflectionUtil.getPrivateField(template, fieldInsideOnly);
  311.                 if (template.isOutsideOnly() || insideOnly) {
  312.                     ReflectionUtil.setPrivateField(template, fieldOutsideonly, Boolean.FALSE);
  313.                     ReflectionUtil.setPrivateField(template, fieldInsideOnly, Boolean.FALSE);
  314.                 }
  315.             }catch (IllegalAccessException e){
  316.                 e.printStackTrace();
  317.             }
  318.         }
  319.     }
  320.  
  321.     @Override
  322.     public void init() {
  323.     }
  324. }
RAW Paste Data
Ledger Nano X - The secure hardware wallet
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top