Advertisement
nyapoleon_legionary

RTMCore.Class

Nov 18th, 2024
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 9.45 KB | None | 0 0
  1. package jp.ngt.rtm;
  2.  
  3. import jp.ngt.ngtlib.util.IMod;
  4. import jp.ngt.rtm.command.RTMCommand;
  5. import jp.ngt.rtm.event.RTMEventHandler;
  6. import jp.ngt.rtm.gui.RTMGuiHandler;
  7. import jp.ngt.rtm.msims.MSIMS;
  8. import jp.ngt.rtm.world.RTMChunkManager;
  9. import net.minecraftforge.common.ForgeChunkManager;
  10. import net.minecraftforge.common.MinecraftForge;
  11. import net.minecraftforge.common.config.Configuration;
  12. import net.minecraftforge.common.config.Property;
  13. import net.minecraftforge.fml.common.FMLLog;
  14. import net.minecraftforge.fml.common.Mod;
  15. import net.minecraftforge.fml.common.ModMetadata;
  16. import net.minecraftforge.fml.common.SidedProxy;
  17. import net.minecraftforge.fml.common.Mod.EventHandler;
  18. import net.minecraftforge.fml.common.Mod.Instance;
  19. import net.minecraftforge.fml.common.Mod.Metadata;
  20. import net.minecraftforge.fml.common.event.FMLInitializationEvent;
  21. import net.minecraftforge.fml.common.event.FMLLoadCompleteEvent;
  22. import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
  23. import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
  24. import net.minecraftforge.fml.common.network.NetworkRegistry;
  25. import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
  26. import org.apache.logging.log4j.Level;
  27.  
  28. @Mod(
  29.    modid = "rtm",
  30.    name = "RealTrainMod",
  31.    version = "2.4.24",
  32.    acceptedMinecraftVersions = "[1.12.2]"
  33. )
  34. public final class RTMCore implements IMod {
  35.    public static final String MODID = "rtm";
  36.    public static final String VERSION = "2.4.24";
  37.    public static final int BUILD_NO = 43;
  38.    @Instance("rtm")
  39.    public static RTMCore instance;
  40.    @Metadata("rtm")
  41.    public static ModMetadata metadata;
  42.    @SidedProxy(
  43.       clientSide = "jp.ngt.rtm.ClientProxy",
  44.       serverSide = "jp.ngt.rtm.CommonProxy"
  45.    )
  46.    public static CommonProxy proxy;
  47.    public static final SimpleNetworkWrapper NETWORK_WRAPPER;
  48.    public static short guiIdSelectEntityModel;
  49.    public static short guiIdSelectTileEntityModel;
  50.    public static short guiIdSelectItemModel;
  51.    public static short guiIdSelectTileEntityTexture;
  52.    public static short guiIdSelectItemTexture;
  53.    public static short guiIdSignboard;
  54.    public static short guiIdFreightCar;
  55.    public static short guiIdItemContainer;
  56.    public static short guiIdTrainControlPanel;
  57.    public static short guiIdTrainWorkBench;
  58.    public static short guiIdSignalConverter;
  59.    public static short guiIdTicketVendor;
  60.    public static short guiIdStation;
  61.    public static short guiIdPaintTool;
  62.    public static short guiIdMovingMachine;
  63.    public static short guiIdNPC;
  64.    public static short guiIdMotorman;
  65.    public static short guiIdRailMarker;
  66.    public static short guiIdCamera;
  67.    public static short guiIdConvertModel;
  68.    public static short guiIdDecoration;
  69.    public static short guiIdSpeaker;
  70.    public static final byte KEY_Forward = 0;
  71.    public static final byte KEY_Back = 1;
  72.    public static final byte KEY_Horn = 2;
  73.    public static final byte KEY_Chime = 3;
  74.    public static final byte KEY_ControlPanel = 4;
  75.    public static final byte KEY_Fire = 5;
  76.    public static final byte KEY_ATS = 6;
  77.    public static final byte KEY_LEFT = 7;
  78.    public static final byte KEY_RIGHT = 8;
  79.    public static final byte KEY_JUMP = 9;
  80.    public static final byte KEY_SNEAK = 10;
  81.    public static final byte KEY_EB = 11;
  82.    public static final String EDIT_VEHICLE = "editVehicle";
  83.    public static final String USE_RAZER = "useRazer";
  84.    public static final String USE_GUN = "useGun";
  85.    public static final String USE_CANNON = "useCannon";
  86.    public static final String EDIT_RAIL = "editRail";
  87.    public static final String DRIVE_TRAIN = "driveTrain";
  88.    public static final String CHANGE_MODEL = "changeModel";
  89.    public static final String EDIT_ORNAMENT = "editOrnament";
  90.    public static float trainSoundVol;
  91.    public static float gunSoundVol;
  92.    public static short railGeneratingDistance;
  93.    public static short railGeneratingHeight;
  94.    public static short markerDisplayDistance;
  95.    public static boolean gunBreakBlock;
  96.    public static boolean deleteBat;
  97.    public static boolean useServerModelPack;
  98.    public static boolean versionCheck;
  99.    public static int mirrorTextureSize;
  100.    public static boolean smoothing;
  101.    public static byte mirrorRenderingFrequency;
  102.    public static int connectorSearchRange;
  103.    public static final int PACKET_SIZE = 512;
  104.    public static final int ATOMIC_BOM_META = 2;
  105.    public static final String AD_URL = "https://dl.dropboxusercontent.com/s/7rpcd4ycxjfnwrr/advertisement.json";
  106.    private static short guiId;
  107.  
  108.    @EventHandler
  109.    public void preInit(FMLPreInitializationEvent event) {
  110.       Configuration cfg = new Configuration(event.getSuggestedConfigurationFile());
  111.  
  112.       try {
  113.          cfg.load();
  114.          Property soundPro1 = cfg.get("Sound", "sound train", 100);
  115.          soundPro1.setComment("Train sound volume. (0 ~ 100)");
  116.          Property soundPro3 = cfg.get("Sound", "sound gun", 100);
  117.          soundPro3.setComment("Gun sound volume. (0 ~ 100)");
  118.          Property railPro1 = cfg.get("Rail", "GeneratingDistance", 64);
  119.          railPro1.setComment("Distance for generating a rail. (default:64, recomended max value:256, It depends on server side)");
  120.          Property railPro2 = cfg.get("Rail", "GeneratingHeight", 8);
  121.          railPro2.setComment("Height for generating a rail. (default:8, recomended max value:256)");
  122.          Property railPro3 = cfg.get("Rail", "MarkerDisplayDistance", 100);
  123.          railPro3.setComment("(default length:100)");
  124.          Property itemPro1 = cfg.get("Item", "Gun Break Block", true);
  125.          Property entityPro1 = cfg.get("Entity", "delete bat", false);
  126.          entityPro1.setComment("Delete bat");
  127.          Property modelPro1 = cfg.get("Model", "use ServerModelPack", false);
  128.          modelPro1.setComment("Download ModelPacks from Server (or Permit download ModelPacks).");
  129.          Property modelPro2 = cfg.get("Model", "do smoothing", true);
  130.          Property modPro1 = cfg.get("Mod", "version check", true);
  131.          modPro1.setComment("");
  132.          Property blockPro1 = cfg.get("Block", "mirror texture size", 512);
  133.          blockPro1.setComment("FrameBuffer size for mirror. (Recomended size : 256~2048)");
  134.          Property blockPro2 = cfg.get("Block", "mirror render frequency", 1);
  135.          blockPro2.setComment("Frequency of rendering mirror. (1 : Full tick)");
  136.          Property blockPro3 = cfg.get("Block", "connector search range", 32);
  137.          blockPro3.setComment("Range of searching connector on right click.");
  138.          trainSoundVol = (float)soundPro1.getInt() / 100.0F;
  139.          gunSoundVol = (float)soundPro3.getInt() / 100.0F;
  140.          railGeneratingDistance = (short)railPro1.getInt();
  141.          railGeneratingHeight = (short)railPro2.getInt();
  142.          markerDisplayDistance = (short)railPro3.getInt();
  143.          gunBreakBlock = itemPro1.getBoolean();
  144.          deleteBat = entityPro1.getBoolean();
  145.          useServerModelPack = modelPro1.getBoolean();
  146.          smoothing = modelPro2.getBoolean();
  147.          versionCheck = modPro1.getBoolean();
  148.          mirrorTextureSize = blockPro1.getInt();
  149.          mirrorRenderingFrequency = (byte)blockPro2.getInt();
  150.          connectorSearchRange = blockPro3.getInt();
  151.       } catch (Exception var19) {
  152.          FMLLog.log(Level.ERROR, var19, "Error Message", new Object[0]);
  153.       } finally {
  154.          cfg.save();
  155.       }
  156.  
  157.       RTMResource.init();
  158.       RTMBlock.init();
  159.       RTMItem.init();
  160.       RTMEntity.init(this);
  161.       RTMRecipe.init();
  162.       RTMPacket.init();
  163.       RTMAdvancement.init();
  164.       NetworkRegistry.INSTANCE.registerGuiHandler(this, new RTMGuiHandler());
  165.       proxy.preInit();
  166.       ForgeChunkManager.setForcedChunkLoadingCallback(this, RTMChunkManager.INSTANCE);
  167.       MinecraftForge.EVENT_BUS.register(RTMChunkManager.INSTANCE);
  168.    }
  169.  
  170.    @EventHandler
  171.    public void init(FMLInitializationEvent event) {
  172.       proxy.init();
  173.       RTMTooltip.init();
  174.       MinecraftForge.EVENT_BUS.register(new RTMEventHandler());
  175.    }
  176.  
  177.    @EventHandler
  178.    public void complete(FMLLoadCompleteEvent event) {
  179.       proxy.complete();
  180.       MSIMS.INSTANCE.loadData();
  181.    }
  182.  
  183.    @EventHandler
  184.    public void handleServerStarting(FMLServerStartingEvent event) {
  185.       RTMCommand.init(event);
  186.    }
  187.  
  188.    private static short getNextGuiID() {
  189.       short var10000 = guiId;
  190.       guiId = (short)(var10000 + 1);
  191.       return var10000;
  192.    }
  193.  
  194.    public String getId() {
  195.       return "rtm";
  196.    }
  197.  
  198.    static {
  199.       NETWORK_WRAPPER = NetworkRegistry.INSTANCE.newSimpleChannel("rtm");
  200.       guiIdSelectEntityModel = getNextGuiID();
  201.       guiIdSelectTileEntityModel = getNextGuiID();
  202.       guiIdSelectItemModel = getNextGuiID();
  203.       guiIdSelectTileEntityTexture = getNextGuiID();
  204.       guiIdSelectItemTexture = getNextGuiID();
  205.       guiIdSignboard = getNextGuiID();
  206.       guiIdFreightCar = getNextGuiID();
  207.       guiIdItemContainer = getNextGuiID();
  208.       guiIdTrainControlPanel = getNextGuiID();
  209.       guiIdTrainWorkBench = getNextGuiID();
  210.       guiIdSignalConverter = getNextGuiID();
  211.       guiIdTicketVendor = getNextGuiID();
  212.       guiIdStation = getNextGuiID();
  213.       guiIdPaintTool = getNextGuiID();
  214.       guiIdMovingMachine = getNextGuiID();
  215.       guiIdNPC = getNextGuiID();
  216.       guiIdMotorman = getNextGuiID();
  217.       guiIdRailMarker = getNextGuiID();
  218.       guiIdCamera = getNextGuiID();
  219.       guiIdConvertModel = getNextGuiID();
  220.       guiIdDecoration = getNextGuiID();
  221.       guiIdSpeaker = getNextGuiID();
  222.    }
  223. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement