Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.jase2z.WUmod;
- import com.wurmonline.server.items.ItemTemplate;
- import com.wurmonline.server.items.ItemTemplateFactory;
- import org.gotti.wurmunlimited.modloader.ReflectionUtil;
- import org.gotti.wurmunlimited.modloader.interfaces.Initable;
- import org.gotti.wurmunlimited.modloader.interfaces.ServerStartedListener;
- import org.gotti.wurmunlimited.modloader.interfaces.WurmMod;
- import java.lang.reflect.Field;
- import java.lang.Math;
- import java.util.*;
- public class BigContainersBAEAMod implements WurmMod, Initable, ServerStartedListener {
- public static int LARGE_CART;
- public static int FORGE;
- public static int JEWELRY_BOWL;
- public static int OVEN;
- public static int ROWING_BOAT;
- public static int SMALL_CART;
- public static int STONE_ALTAR;
- public static int BSB;
- public static int FSB;
- public static int TRASH_HEAP;
- public static int PELT;
- public static int BK_MUSHROOM;
- public static int GN_MUSHROOM;
- public static int YL_MUSHROOM;
- public static int BL_MUSHROOM;
- public static int BN_MUSHROOM;
- public static int RD_MUSHROOM;
- public static int FELLED_TREE;
- public static int INK_SAC;
- public static int COCHINEAL;
- public static int SADDLE;
- public static int STONE_KEYSTONE;
- public static int MARBLE_KEYSTONE;
- public static int BASS;
- public static int CARP;
- public static int CATFISH;
- public static int SNOOK;
- public static int HERRING;
- public static int PIKE;
- public static int ROACH;
- public static int TROUT;
- public static int PERCH;
- public static int MARLIN;
- public static int BLUE_SHARK;
- public static int WHITE_SHARK;
- public static int OCTOPUS;
- public static int SAILFISH;
- public static int DORADO;
- public static int TUNA;
- public static int F_FISHING_LINE;
- public static int WOAD;
- static {
- BigContainersBAEAMod.LARGE_CART = 539;
- BigContainersBAEAMod.FORGE = 180;
- BigContainersBAEAMod.JEWELRY_BOWL = 326;
- BigContainersBAEAMod.OVEN = 178;
- BigContainersBAEAMod.ROWING_BOAT = 490;
- BigContainersBAEAMod.SMALL_CART = 186;
- BigContainersBAEAMod.STONE_ALTAR = 323;
- BigContainersBAEAMod.BSB = 662;
- BigContainersBAEAMod.FSB = 661;
- BigContainersBAEAMod.TRASH_HEAP = 670;
- BigContainersBAEAMod.PELT = 313;
- BigContainersBAEAMod.BK_MUSHROOM = 247;
- BigContainersBAEAMod.GN_MUSHROOM = 246;
- BigContainersBAEAMod.YL_MUSHROOM = 249;
- BigContainersBAEAMod.BL_MUSHROOM = 250;
- BigContainersBAEAMod.BN_MUSHROOM = 248;
- BigContainersBAEAMod.RD_MUSHROOM = 251;
- BigContainersBAEAMod.FELLED_TREE = 385;
- BigContainersBAEAMod.INK_SAC = 752;
- BigContainersBAEAMod.COCHINEAL = 439;
- BigContainersBAEAMod.SADDLE = 621;
- BigContainersBAEAMod.STONE_KEYSTONE = 905;
- BigContainersBAEAMod.MARBLE_KEYSTONE = 906;
- BigContainersBAEAMod.BASS = 158;
- BigContainersBAEAMod.CARP = 164;
- BigContainersBAEAMod.CATFISH = 160;
- BigContainersBAEAMod.SNOOK = 161;
- BigContainersBAEAMod.HERRING = 159;
- BigContainersBAEAMod.PIKE = 157;
- BigContainersBAEAMod.ROACH = 162;
- BigContainersBAEAMod.TROUT = 165;
- BigContainersBAEAMod.PERCH = 163;
- BigContainersBAEAMod.MARLIN = 569;
- BigContainersBAEAMod.BLUE_SHARK = 570;
- BigContainersBAEAMod.WHITE_SHARK = 571;
- BigContainersBAEAMod.OCTOPUS = 572;
- BigContainersBAEAMod.SAILFISH = 573;
- BigContainersBAEAMod.DORADO = 574;
- BigContainersBAEAMod.TUNA = 575;
- BigContainersBAEAMod.F_FISHING_LINE = 150;
- BigContainersBAEAMod.WOAD = 440;
- }
- public void onServerStarted() {
- // ********************** Get needed fields **********************
- Map<Integer, ItemTemplate> templates = null;
- Field fieldOnePerTile = null;
- Field fieldUsesSpecifiedContainerSizes = null;
- Field fieldIsTransportable = null;
- Field fieldCentimetersX = null;
- Field fieldCentimetersY = null;
- Field fieldCentimetersZ = null;
- Field fieldVolume = null;
- Field fieldContainerCentimetersX = null;
- Field fieldContainerCentimetersY = null;
- Field fieldContainerCentimetersZ = null;
- Field fieldContainerVolume = null;
- Field fieldWeight = null;
- Field fieldBulk = null;
- Field fieldCombine = null;
- Field fieldOutsideonly = null;
- Field fieldInsideOnly = null;
- try {
- templates = ReflectionUtil.getPrivateField(
- ItemTemplateFactory.class, ReflectionUtil.getField(ItemTemplateFactory.class, "templates"));
- fieldOnePerTile = ReflectionUtil.getField(ItemTemplate.class, "onePerTile");
- fieldUsesSpecifiedContainerSizes = ReflectionUtil.getField(ItemTemplate.class, "usesSpecifiedContainerSizes");
- fieldIsTransportable = ReflectionUtil.getField(ItemTemplate.class, "isTransportable");
- fieldCentimetersX = ReflectionUtil.getField(ItemTemplate.class, "centimetersX");
- fieldCentimetersY = ReflectionUtil.getField(ItemTemplate.class, "centimetersY");
- fieldCentimetersZ = ReflectionUtil.getField(ItemTemplate.class, "centimetersZ");
- fieldVolume = ReflectionUtil.getField(ItemTemplate.class, "volume");
- fieldContainerCentimetersX = ReflectionUtil.getField(ItemTemplate.class, "containerCentimetersX");
- fieldContainerCentimetersY = ReflectionUtil.getField(ItemTemplate.class, "containerCentimetersY");
- fieldContainerCentimetersZ = ReflectionUtil.getField(ItemTemplate.class, "containerCentimetersZ");
- fieldContainerVolume = ReflectionUtil.getField(ItemTemplate.class, "containerVolume");
- fieldWeight = ReflectionUtil.getField(ItemTemplate.class, "weight");
- fieldBulk = ReflectionUtil.getField(ItemTemplate.class, "bulk");
- fieldCombine = ReflectionUtil.getField(ItemTemplate.class, "combine");
- fieldOutsideonly = ReflectionUtil.getField(ItemTemplate.class, "outsideonly");
- fieldInsideOnly = ReflectionUtil.getField(ItemTemplate.class, "insideOnly");
- } catch (IllegalAccessException | NoSuchFieldException | NullPointerException e){
- e.printStackTrace();
- }
- assert fieldOnePerTile != null;
- assert fieldUsesSpecifiedContainerSizes != null;
- assert fieldIsTransportable != null;
- assert fieldCentimetersX != null;
- assert fieldCentimetersY != null;
- assert fieldCentimetersZ != null;
- assert fieldVolume != null;
- assert fieldContainerCentimetersX != null;
- assert fieldContainerCentimetersY != null;
- assert fieldContainerCentimetersZ != null;
- assert fieldContainerVolume != null;
- assert fieldWeight != null;
- assert fieldBulk != null;
- assert fieldCombine != null;
- assert fieldOutsideonly != null;
- assert fieldInsideOnly != null;
- // ******************** start iteration through all the templates******************************
- for ( ItemTemplate template : templates.values()) {
- // *******************Set internal sizes big for select templates.*************************
- Integer a = template.getTemplateId();
- if (a == LARGE_CART || a == FORGE || a == JEWELRY_BOWL || a == OVEN || a == ROWING_BOAT ||
- a == SMALL_CART || a == STONE_ALTAR || a == BSB || a == FSB || a == TRASH_HEAP) {
- if (!template.usesSpecifiedContainerSizes()) {
- try {
- ReflectionUtil.setPrivateField(template, fieldUsesSpecifiedContainerSizes, Boolean.TRUE);
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- }
- }
- template.setContainerSize(1200, 1200, 1200);
- }
- // *******************Make all internal sizes uniform****************
- if (template.usesSpecifiedContainerSizes()){
- try {
- int contX = ReflectionUtil.getPrivateField(template, fieldContainerCentimetersX);
- int contY = ReflectionUtil.getPrivateField(template, fieldContainerCentimetersY);
- int contZ = ReflectionUtil.getPrivateField(template, fieldContainerCentimetersZ);
- int uniform = Math.max(new Double(Math.ceil(Math.cbrt(contX * contY * contZ))).intValue(), 1);
- ReflectionUtil.setPrivateField(template, fieldContainerCentimetersX, uniform);
- ReflectionUtil.setPrivateField(template, fieldContainerCentimetersY, uniform);
- ReflectionUtil.setPrivateField(template, fieldContainerCentimetersZ, uniform);
- ReflectionUtil.setPrivateField(template, fieldContainerVolume, uniform * uniform * uniform);
- }catch (IllegalAccessException e) {
- e.printStackTrace();
- }
- }
- //*********Remove one per tile restriction.*****************
- Boolean onePerTile;
- try {
- onePerTile = ReflectionUtil.getPrivateField(template, fieldOnePerTile);
- if (onePerTile) {
- ReflectionUtil.setPrivateField(template, fieldOnePerTile, Boolean.FALSE);
- }
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- }
- //***************Add Transportable flag to select templates**********************
- if (a == STONE_ALTAR || a == ROWING_BOAT || a == TRASH_HEAP) {
- if (!template.isTransportable()){
- try {
- ReflectionUtil.setPrivateField(template, fieldIsTransportable, Boolean.TRUE);
- } catch (IllegalAccessException e){
- e.printStackTrace();
- }
- }
- }
- //*****************Make external dimensions uniform**********************
- try {
- int sizeX = ReflectionUtil.getPrivateField(template, fieldCentimetersX);
- int sizeY = ReflectionUtil.getPrivateField(template, fieldCentimetersY);
- int sizeZ = ReflectionUtil.getPrivateField(template, fieldCentimetersZ);
- int uniform = Math.max(new Double(Math.floor(Math.cbrt(sizeX * sizeY * sizeZ))).intValue(), 1);
- ReflectionUtil.setPrivateField(template, fieldCentimetersX, uniform);
- ReflectionUtil.setPrivateField(template, fieldCentimetersY, uniform);
- ReflectionUtil.setPrivateField(template, fieldCentimetersZ, uniform);
- ReflectionUtil.setPrivateField(template, fieldVolume, uniform * uniform * uniform );
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- }
- //*****************resize weight for select templates**********************
- if (a == PELT || a == BK_MUSHROOM || a == GN_MUSHROOM || a == YL_MUSHROOM || a == BL_MUSHROOM ||
- a == BN_MUSHROOM || a == RD_MUSHROOM) {
- int sizeX = 1;
- int sizeY = 1;
- int sizeZ = 1;
- int weight = 10;
- if (a == PELT) {
- sizeX = 10;
- sizeY = 10;
- sizeZ = 10;
- weight = 100;
- }
- if (a == BK_MUSHROOM) {
- sizeX = 2;
- sizeY = 2;
- sizeZ = 2;
- weight = 10;
- }
- if (a == GN_MUSHROOM) {
- sizeX = 2;
- sizeY = 2;
- sizeZ = 2;
- weight = 10;
- }
- if (a == YL_MUSHROOM) {
- sizeX = 10;
- sizeY = 10;
- sizeZ = 10;
- weight = 1000;
- }
- if (a == BL_MUSHROOM) {
- sizeX = 10;
- sizeY = 10;
- sizeZ = 10;
- weight = 1000;
- }
- if (a == BN_MUSHROOM) {
- sizeX = 10;
- sizeY = 10;
- sizeZ = 10;
- weight = 1000;
- }
- if (a == RD_MUSHROOM) {
- sizeX = 10;
- sizeY = 10;
- sizeZ = 10;
- weight = 1000;
- }
- try {
- ReflectionUtil.setPrivateField(template, fieldCentimetersX, sizeX);
- ReflectionUtil.setPrivateField(template, fieldCentimetersY, sizeY);
- ReflectionUtil.setPrivateField(template, fieldCentimetersZ, sizeZ);
- ReflectionUtil.setPrivateField(template, fieldWeight, weight);
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- }
- }
- //****************add bulk flag to select templates***********************
- if (a == FELLED_TREE || a == PELT || a == SADDLE || a == STONE_KEYSTONE || a == MARBLE_KEYSTONE ||
- a == BASS || a == CARP || a == CATFISH || a == SNOOK || a == HERRING || a == PIKE || a == ROACH ||
- a == TROUT || a == PERCH || a == MARLIN || a == BLUE_SHARK || a == WHITE_SHARK || a == OCTOPUS ||
- a == SAILFISH || a == DORADO || a == TUNA || a == BK_MUSHROOM || a == GN_MUSHROOM ||
- a == YL_MUSHROOM || a == BL_MUSHROOM || a == BN_MUSHROOM || a == RD_MUSHROOM || a == F_FISHING_LINE){
- try {
- ReflectionUtil.setPrivateField(template, fieldBulk, Boolean.TRUE);
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- }
- }
- //***************add combine flags to select templates*********************
- if (a == COCHINEAL || a == WOAD){
- try {
- ReflectionUtil.setPrivateField(template, fieldCombine, Boolean.TRUE);
- }catch (IllegalAccessException e) {
- e.printStackTrace();
- }
- }
- //*****************remove outside and inside only flags from all**********************
- Boolean insideOnly;
- try {
- insideOnly = ReflectionUtil.getPrivateField(template, fieldInsideOnly);
- if (template.isOutsideOnly() || insideOnly) {
- ReflectionUtil.setPrivateField(template, fieldOutsideonly, Boolean.FALSE);
- ReflectionUtil.setPrivateField(template, fieldInsideOnly, Boolean.FALSE);
- }
- }catch (IllegalAccessException e){
- e.printStackTrace();
- }
- }
- }
- @Override
- public void init() {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement