Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

More cleaning #246

Merged
merged 13 commits into from
Oct 15, 2023
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//version: 1696265388
//version: 1696952014
/*
DO NOT CHANGE THIS FILE!
Also, you may replace this file at any time if there is an update available.
Expand Down Expand Up @@ -793,7 +793,7 @@ ext.java17PatchDependenciesCfg = configurations.create("java17PatchDependencies"
}

dependencies {
def lwjgl3ifyVersion = '1.5.0'
def lwjgl3ifyVersion = '1.5.1'
if (modId != 'lwjgl3ify') {
java17Dependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}")
}
Expand Down
140 changes: 5 additions & 135 deletions src/main/java/com/github/technus/tectech/TecTech.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,11 @@
import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE;
import static gregtech.api.enums.Mods.COFHCore;

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.Collection;
import java.util.Iterator;

import net.minecraftforge.common.MinecraftForge;

import com.github.technus.tectech.loader.MainLoader;
import com.github.technus.tectech.loader.TecTechConfig;
import com.github.technus.tectech.loader.gui.CreativeTabTecTech;
import com.github.technus.tectech.mechanics.commands.ConvertFloat;
import com.github.technus.tectech.mechanics.commands.ConvertInteger;
import com.github.technus.tectech.mechanics.data.ChunkDataHandler;
import com.github.technus.tectech.mechanics.data.PlayerPersistence;
import com.github.technus.tectech.mechanics.enderStorage.EnderWorldSavedData;
import com.github.technus.tectech.nei.IMCForNEI;
import com.github.technus.tectech.proxy.CommonProxy;
Expand All @@ -30,12 +21,8 @@
import cpw.mods.fml.common.event.FMLLoadCompleteEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerAboutToStartEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import eu.usrv.yamcore.auxiliary.IngameErrorLog;
import eu.usrv.yamcore.auxiliary.LogHelper;
import gregtech.GT_Mod;
import gregtech.common.GT_Proxy;

@Mod(
modid = Reference.MODID,
Expand Down Expand Up @@ -63,12 +50,9 @@ public class TecTech {
public static final LogHelper LOGGER = new LogHelper(Reference.MODID);
public static CreativeTabTecTech creativeTabTecTech;

private static IngameErrorLog moduleAdminErrorLogs;
public static TecTechConfig configTecTech;

public static EnderWorldSavedData enderWorldSavedData;
public static ChunkDataHandler chunkDataHandler;
public static PlayerPersistence playerPersistence;

/**
* For Loader.isModLoaded checks during the runtime
Expand All @@ -77,17 +61,8 @@ public class TecTech {

public static final byte tectechTexturePage1 = 8;

public static void AddLoginError(String pMessage) {
if (moduleAdminErrorLogs != null) {
moduleAdminErrorLogs.AddErrorLogOnAdminJoin(pMessage);
}
}

static {
MainLoader.staticLoad();
}

@Mod.EventHandler
@SuppressWarnings("unused")
public void PreLoad(FMLPreInitializationEvent PreEvent) {
LOGGER.setDebugOutput(true);

Expand All @@ -103,17 +78,9 @@ public void PreLoad(FMLPreInitializationEvent PreEvent) {
if (configTecTech.MOD_ADMIN_ERROR_LOGS) {
LOGGER.setDebugOutput(DEBUG_MODE);
LOGGER.debug("moduleAdminErrorLogs is enabled");
moduleAdminErrorLogs = new IngameErrorLog();
IngameErrorLog moduleAdminErrorLogs = new IngameErrorLog();
}

playerPersistence = new PlayerPersistence("tec");
FMLCommonHandler.instance().bus().register(playerPersistence);
MinecraftForge.EVENT_BUS.register(playerPersistence);

chunkDataHandler = new ChunkDataHandler();
FMLCommonHandler.instance().bus().register(chunkDataHandler);
MinecraftForge.EVENT_BUS.register(chunkDataHandler);

enderWorldSavedData = new EnderWorldSavedData();
FMLCommonHandler.instance().bus().register(enderWorldSavedData);
MinecraftForge.EVENT_BUS.register(enderWorldSavedData);
Expand All @@ -122,124 +89,27 @@ public void PreLoad(FMLPreInitializationEvent PreEvent) {
}

@Mod.EventHandler
@SuppressWarnings("unused")
public void Load(FMLInitializationEvent event) {
hasCOFH = COFHCore.isModLoaded();

if (configTecTech.DISABLE_MATERIAL_LOADING_FFS) {
try {
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
Field field = GT_Proxy.class.getDeclaredField("mEvents");
field.setAccessible(true);
modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
field.set(GT_Mod.gregtechproxy, new Collection<Object>() {

@Override
public int size() {
return 0;
}

@Override
public boolean isEmpty() {
return true;
}

@Override
public boolean contains(Object o) {
return false;
}

@Override
public Iterator<Object> iterator() {
return new Iterator<Object>() {

@Override
public boolean hasNext() {
return false;
}

@Override
public Object next() {
return null;
}
};
}

@Override
public Object[] toArray() {
return new Object[0];
}

@Override
public boolean add(Object o) {
return false;
}

@Override
public boolean remove(Object o) {
return false;
}

@Override
public boolean addAll(Collection<?> c) {
return false;
}

@Override
public void clear() {}

@Override
public boolean retainAll(Collection<?> c) {
return false;
}

@Override
public boolean removeAll(Collection<?> c) {
return false;
}

@Override
public boolean containsAll(Collection<?> c) {
return false;
}

@SuppressWarnings("unchecked")
@Override
public Object[] toArray(Object[] a) {
return new Object[0];
}
});
} catch (NoSuchFieldException | IllegalAccessException e) {
LOGGER.error(Reference.MODID + " could not disable material loading!");
}
}

MainLoader.load();
MainLoader.addAfterGregTechPostLoadRunner();
IMCForNEI.IMCSender();
}

@Mod.EventHandler
@SuppressWarnings("unused")
public void PostLoad(FMLPostInitializationEvent PostEvent) {
MainLoader.postLoad();
}

@Mod.EventHandler
public void serverLoad(FMLServerStartingEvent pEvent) {
pEvent.registerServerCommand(new ConvertInteger());
pEvent.registerServerCommand(new ConvertFloat());
}

@Mod.EventHandler
@SuppressWarnings("unused")
public void onLoadCompleted(FMLLoadCompleteEvent event) {
eyeOfHarmonyRecipeStorage = new EyeOfHarmonyRecipeStorage();
}

public static EyeOfHarmonyRecipeStorage eyeOfHarmonyRecipeStorage = null;

@Mod.EventHandler
public void onServerAboutToStart(FMLServerAboutToStartEvent aEvent) {
chunkDataHandler.clearData();
playerPersistence.clearData();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ private void computeMemory(Iterable<ItemStack> components) {
int memory = 0;
for (ItemStack component : components) {
Item driver = Driver.driverFor(component);
if (driver instanceof Memory) {
Memory memoryDriver = (Memory) driver;
if (driver instanceof Memory memoryDriver) {
memory += memoryDriver.amount(component) * 256; // in integers
} // else if (driver instanceof DriverEEPROM$) {

Expand Down
Loading