Skip to content

Commit

Permalink
Cleanup codebase (#19)
Browse files Browse the repository at this point in the history
* update buildscript + deps

* applyDecompilerCleanupToMain

* remove commented out code

* move to tags based injected version

* cleanup code

* remove .bak files
  • Loading branch information
mist475 authored Apr 1, 2024
1 parent a767b0f commit 1856099
Show file tree
Hide file tree
Showing 131 changed files with 455 additions and 2,264 deletions.
2 changes: 1 addition & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Add your dependencies here

dependencies {
implementation('com.github.GTNewHorizons:NotEnoughItems:2.5.19-GTNH:dev')
implementation('com.github.GTNewHorizons:NotEnoughItems:2.5.25-GTNH:dev')

shadowImplementation('au.com.bytecode:opencsv:2.4')
}
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ developmentEnvironmentUserName = Developer

# Enables using modern Java syntax (up to version 17) via Jabel, while still targeting JVM 8.
# See https://github.com/bsideup/jabel for details on how this works.
enableModernJavaSyntax = false
enableModernJavaSyntax = true

# Enables injecting missing generics into the decompiled source code for a better coding experience.
# Turns most publicly visible List, Map, etc. into proper List<E>, Map<K, V> types.
enableGenericInjection = false
enableGenericInjection = true

# Generate a class with a String field for the mod version named as defined below.
# If generateGradleTokenClass is empty or not missing, no such class will be generated.
# If gradleTokenVersion is empty or missing, the field will not be present in the class.
generateGradleTokenClass =
generateGradleTokenClass = mcp.mobius.waila.Tags

# Name of the token containing the project's current version to generate/replace.
gradleTokenVersion = GRADLETOKEN_VERSION
Expand All @@ -70,7 +70,7 @@ gradleTokenGroupName =
# The string's content will be replaced with your mod's version when compiled. You should use this to specify your mod's
# version in @Mod([...], version = VERSION, [...]).
# Leave these properties empty to skip individual token replacements.
replaceGradleTokenInFile = Waila.java
replaceGradleTokenInFile =

# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise, you can
# leave this property empty.
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pluginManagement {
}

plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.14'
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.19'
}


27 changes: 2 additions & 25 deletions src/main/java/mcp/mobius/waila/Waila.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,9 @@
@Mod(
modid = "Waila",
name = "Waila",
version = "GRADLETOKEN_VERSION",
version = Tags.GRADLETOKEN_VERSION,
dependencies = "after:NotEnoughItems@[1.0.4.0,)",
acceptableRemoteVersions = "*")
/*
* @NetworkMod(channels = {"Waila"},clientSideRequired=false, serverSideRequired=false, connectionHandler =
* WailaConnectionHandler.class, packetHandler = WailaPacketHandler.class, versionBounds="[1.5.0,)") //packetHandler =
* WailaPacketHandler.class)
*/

public class Waila {

// The instance of your mod that Forge uses.
Expand Down Expand Up @@ -75,7 +69,7 @@ public void initialize(FMLInitializationEvent event) {
eBus.setAccessible(true);
EventBus FMLbus = (EventBus) eBus.get(FMLCommonHandler.instance().findContainerFor(this));
FMLbus.register(this);
} catch (Throwable t) {}
} catch (Throwable ignored) {}

if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) {
MinecraftForge.EVENT_BUS.register(new DecoratorRenderer());
Expand All @@ -90,29 +84,12 @@ public void initialize(FMLInitializationEvent event) {
public void postInit(FMLPostInitializationEvent event) {
proxy.registerHandlers();
ModIdentification.init();

/*
* if (ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_KEYBIND, true)){
* for (String key: ModIdentification.keyhandlerStrings.keySet()){ String orig = I18n.getString(key); if
* (orig.equals(key)) orig = LanguageRegistry.instance().getStringLocalization(key); if (orig.equals(key)) orig
* = LangUtil.translateG(key); if (orig.isEmpty()) orig = key; String modif; if (orig.startsWith("[") ||
* orig.contains(":")) modif = orig; else{ String id = ModIdentification.keyhandlerStrings.get(key); if
* (id.contains(".")) id = id.split("\\.")[0]; if (id.length() > 10) id = id.substring(0, 11); if (id.isEmpty())
* id = "????"; modif = String.format("[%s] %s", id, orig); }
* LanguageRegistry.instance().addStringLocalization(key, modif); } }
*/

}

@Subscribe
public void loadComplete(FMLLoadCompleteEvent event) {
proxy.registerMods();
proxy.registerIMCs();

/*
* String[] ores = OreDictionary.getOreNames(); for (String s : ores) for (ItemStack stack :
* OreDictionary.getOres(s)) System.out.printf("%s : %s\n", s, stack);
*/
}

@EventHandler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

public class AgricultureModule {

public static Class BlockCrop = null;
public static Class<?> BlockCrop = null;

public static void register() {
try {
Class Agriculture = Class.forName("com.teammetallurgy.agriculture.Agriculture");
Class.forName("com.teammetallurgy.agriculture.Agriculture");
Waila.log.log(Level.INFO, "Agriculture mod found.");
} catch (ClassNotFoundException e) {
Waila.log.log(Level.INFO, "[Agriculture] Agriculture mod not found.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,9 @@

public class BCModule {

public static Class TileTank = null;
public static Class<?> TileTank = null;
public static Method TileTank_getTankInfo = null;

// public static Class IPowerReceptor = null;
// public static Class PipeTransportPower = null;
// public static Class TileGenericPipe = null;
// public static Class TileEngine = null;

public static void register() {
try {
TileTank = Class.forName("buildcraft.factory.TileTank");
Expand All @@ -31,10 +26,8 @@ public static void register() {

} catch (ClassNotFoundException e) {
Waila.log.log(Level.WARN, "[BC] Class not found. " + e);
return;
} catch (NoSuchMethodException e) {
Waila.log.log(Level.WARN, "[BC] Method not found." + e);
return;
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, I
int liquidAmount = stack != null ? stack.amount : 0;
int capacity = tank != null ? tank.capacity : 0;

if (ConfigHandler.instance().getConfig("bc.tankamount"))
currenttip.add(String.valueOf(liquidAmount) + "/" + String.valueOf(capacity) + " mB");
if (ConfigHandler.instance().getConfig("bc.tankamount")) currenttip.add(liquidAmount + "/" + capacity + " mB");

return currenttip;
}
Expand All @@ -63,14 +62,12 @@ public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, I
}

public FluidTankInfo getTank(IWailaDataAccessor accessor) {
FluidTankInfo tank = null;
FluidTankInfo tank;
try {
tank = ((FluidTankInfo[]) BCModule.TileTank_getTankInfo
.invoke(BCModule.TileTank.cast(accessor.getTileEntity()), ForgeDirection.UNKNOWN))[0];
} catch (Exception e) {
Waila.log.log(
Level.ERROR,
"[BC] Unhandled exception trying to access a tank for display !.\n" + String.valueOf(e));
Waila.log.log(Level.ERROR, "[BC] Unhandled exception trying to access a tank for display !.\n" + e);
return null;
}
return tank;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,6 @@

public class CarpentersModule {

public static Class TEBase = null;
public static Class BlockCarpentersDoor = null;
public static Class BlockCarpentersHatch = null;

public static void register() {
/*
* try{ Class CarpentersBlocks = Class.forName("carpentersblocks.CarpentersBlocks"); Waila.log.log(Level.INFO,
* "CarpentersBlocks mod found."); } catch (ClassNotFoundException e){ Waila.log.log(Level.INFO,
* "[CarpentersBlocks] CarpentersBlocks mod not found."); return; } try{ TEBase =
* Class.forName("carpentersblocks.tileentity.TEBase"); BlockCarpentersDoor =
* Class.forName("carpentersblocks.block.BlockCarpentersDoor"); BlockCarpentersHatch =
* Class.forName("carpentersblocks.block.BlockCarpentersHatch"); } catch (ClassNotFoundException e){
* Waila.log.log(Level.WARNING, "[CarpentersBlocks] Class not found. " + e); return; } catch (Exception e) {
* Waila.log.log(Level.WARNING, "[CarpentersBlocks] Error while loading module. " + e); return; }
* ModuleRegistrar.instance().addConfig("Carpenter's Blocks", "carpenters.hide");
* ModuleRegistrar.instance().registerStackProvider(new HUDCarpentersBlocksTE(), BlockCarpentersDoor);
* ModuleRegistrar.instance().registerStackProvider(new HUDCarpentersBlocksTE(), BlockCarpentersHatch);
* ModuleRegistrar.instance().registerSyncedNBTKey("data", TEBase);
* ModuleRegistrar.instance().registerSyncedNBTKey("cover_6", TEBase);
*/
}
public static void register() {}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,6 @@ public class HUDCarpentersBlocksTE implements IWailaDataProvider {

@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
/*
* if (!config.getConfig("carpenters.hide")) return null; NBTTagCompound tag = accessor.getNBTData(); short data
* = tag.getShort("data"); short cover = tag.getShort("cover_6");
* if(CarpentersModule.BlockCarpentersDoor.isInstance(accessor.getBlock())){ int type = data & 0x7; if (type !=
* 5) return null; if (cover == 0) return null; return new ItemStack(cover & 0xfff, 0, (cover & 0xf000) >>> 12);
* } else if (CarpentersModule.BlockCarpentersHatch.isInstance(accessor.getBlock())){ int type = data & 0x7; if
* (type != 0) return null; if (cover == 0) return null; return new ItemStack(cover & 0xfff, 0, (cover & 0xf000)
* >>> 12); }
*/
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@

public class EnderIOModule {

public static Class TileCapacitorBank = null;
public static Class<?> TileCapacitorBank = null;
public static Method TCB_getMaxInput = null;
public static Method TCB_getMaxOutput = null;
public static Method TCB_getEnergyStored = null;
public static Method TCB_getMaxEnergyStored = null;
public static Method TCB_getMaxIO = null;

public static Class TileTesseract = null;
public static Class<?> TileTesseract = null;

public static void register() {
try {
Class ModClass = Class.forName("crazypants.enderio.EnderIO");
Class.forName("crazypants.enderio.EnderIO");
Waila.log.log(Level.INFO, "EnderIO mod found.");
} catch (ClassNotFoundException e) {
Waila.log.log(Level.INFO, "[EnderIO] EnderIO mod not found.");
Expand All @@ -44,9 +44,6 @@ public static void register() {
} catch (NoSuchMethodException e) {
Waila.log.log(Level.WARN, "[EnderStorage] Method not found." + e);
return;
// } catch (NoSuchFieldException e){
// mod_Waila.log.log(Level.WARNING, "[EnderStorage] Field not found." + e);
// return;
} catch (Exception e) {
Waila.log.log(Level.WARN, "[EnderStorage] Unhandled exception." + e);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, I
String channel = "%s : %s%s%s %s";
String freq;
String frequser;
String owner;

if (config.getConfig("enderio.channel")) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@

public class EnderStorageModule {

public static Class TileFrequencyOwner = null;
public static Class<?> TileFrequencyOwner = null;
public static Field TileFrequencyOwner_Freq = null;

public static Class EnderStorageManager = null;
public static Class<?> EnderStorageManager = null;
public static Method GetColourFromFreq = null;

public static Class TileEnderTank = null;
public static Class<?> TileEnderTank = null;

public static void register() {
try {
Class EnderStorage = Class.forName("codechicken.enderstorage.EnderStorage");
Class.forName("codechicken.enderstorage.EnderStorage");
Waila.log.log(Level.INFO, "EnderStorage mod found.");
} catch (ClassNotFoundException e) {
Waila.log.log(Level.INFO, "[EnderStorage] EnderStorage mod not found.");
Expand Down
24 changes: 4 additions & 20 deletions src/main/java/mcp/mobius/waila/addons/etb/ETBModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,22 @@

public class ETBModule {

public static Class TileSocket = null;
public static Class<?> TileSocket = null;
public static Field Socket_sides = null;
public static Field Socket_configs = null;
// public static Field Socket_sideID = null;
// public static Field Socket_sideMeta = null;
// public static Field Socket_facID = null;
// public static Field Socket_facMeta = null;

public static Class SocketsMod = null;
public static Class<?> SocketsMod = null;
public static Field module = null;

public static Class SideConfig = null;
public static Class<?> SideConfig = null;
public static Field SC_tank = null;
public static Field SC_inventory = null;
public static Field SC_rsControl = null;
public static Field SC_rsLatch = null;

public static void register() {
try {
Class ModClass = Class.forName("emasher.sockets.TileSocket");
Class.forName("emasher.sockets.TileSocket");
Waila.log.log(Level.INFO, "Engineer Toolbox mod found.");
} catch (ClassNotFoundException e) {
Waila.log.log(Level.INFO, "[Engineer Toolbox] Engineer Toolbox mod not found.");
Expand All @@ -40,18 +36,9 @@ public static void register() {
TileSocket = Class.forName("emasher.sockets.TileSocket");
Socket_sides = TileSocket.getField("sides");
Socket_configs = TileSocket.getField("configs");
// Socket_sideID = TileSocket.getField("sideID");
// Socket_sideMeta = TileSocket.getField("sideMeta");
// Socket_facID = TileSocket.getField("facID");
// Socket_facMeta = TileSocket.getField("facMeta");

SocketsMod = Class.forName("emasher.sockets.SocketsMod");
module = SocketsMod.getField("module");
// module = (Item)SocketsMod.getField("module").get(null);
/*
* if (module == null){ mod_Waila.log.log(Level.WARNING, "[Engineer Toolbox] module field is null !");
* return; }
*/

SideConfig = Class.forName("emasher.api.SideConfig");
SC_tank = SideConfig.getField("tank");
Expand All @@ -62,9 +49,6 @@ public static void register() {
} catch (ClassNotFoundException e) {
Waila.log.log(Level.WARN, "[Engineer Toolbox] Class not found. " + e);
return;
// } catch (NoSuchMethodException e){
// Waila.log.log(Level.WARN, "[Engineer Toolbox] Method not found." + e);
// return;
} catch (NoSuchFieldException e) {
Waila.log.log(Level.WARN, "[Engineer Toolbox] Field not found." + e);
return;
Expand Down
10 changes: 2 additions & 8 deletions src/main/java/mcp/mobius/waila/addons/etb/HUDHandlerSocket.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, I

String configstr = "[ ";

if (tank != -1) configstr += "\u00a79" + String.valueOf(tank) + " ";
if (tank != -1) configstr += "\u00a79" + tank + " ";

if (inventory != -1) configstr += "\u00a7a" + String.valueOf(inventory) + " ";
if (inventory != -1) configstr += "\u00a7a" + inventory + " ";

if (rsControl[0] || rsControl[1] || rsControl[2]) {
configstr += "\u00a7c";
Expand All @@ -76,12 +76,6 @@ public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, I

if (!configstr.equals("[ \u00a7r]")) tipstr += " " + configstr;

/*
* if ((tank != -1) && (inventory != -1)) tipstr += String.format("[ \u00a79%d \u00a7a%d \u00a7r]",
* tank, inventory); else if (tank != -1) tipstr += String.format("[ \u00a79%d \u00a7r]", tank);
* else if (inventory != -1) tipstr += String.format("[ \u00a7a%d \u00a7r]", inventory);
*/

currenttip.add(tipstr);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@

public class ExtraUtilitiesModule {

public static Class ModExtraUtilities = null;
public static Class TileEntityDrum = null;
public static Class<?> TileEntityDrum = null;

public static void register() {

try {
Class ModExtraUtilities = Class.forName("com.rwtema.extrautils.ExtraUtils");
Class.forName("com.rwtema.extrautils.ExtraUtils");
Waila.log.log(Level.INFO, "ExtraUtilities mod found.");
} catch (ClassNotFoundException e) {
Waila.log.log(Level.INFO, "[ExtraUtilities] ExtraUtilities mod not found.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

public class GravestoneModule {

public static Class BlockGraveStone = null;
public static Class<?> BlockGraveStone = null;

public static void register() {

try {
Class ModGravestone = Class.forName("GraveStone.ModGraveStone");
Class.forName("GraveStone.ModGraveStone");
Waila.log.log(Level.INFO, "GraveStone mod found.");
} catch (ClassNotFoundException e) {
Waila.log.log(Level.INFO, "[GraveStone] GraveStone mod not found.");
Expand Down
Loading

0 comments on commit 1856099

Please sign in to comment.