Skip to content

Commit

Permalink
Fix crash because of sided field assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
thecatcore committed Feb 24, 2024
1 parent 7c06736 commit 19c4f45
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 14 deletions.
1 change: 1 addition & 0 deletions apron-stapi-compat/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ loom {
dependencies {
implementation "org.slf4j:slf4j-api:1.8.0-beta4"
implementation 'org.apache.logging.log4j:log4j-slf4j18-impl:2.17.2'
implementation "blue.endless:jankson:1.2.1"

modImplementation "net.modificationstation:StationAPI:${project.stapi_version}"

Expand Down
1 change: 1 addition & 0 deletions apron-stapi/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ tasks.withType(JavaCompile).configureEach {
dependencies {
implementation "org.slf4j:slf4j-api:1.8.0-beta4"
implementation 'org.apache.logging.log4j:log4j-slf4j18-impl:2.17.2'
implementation "blue.endless:jankson:1.2.1"

modImplementation "net.modificationstation:StationAPI:${project.stapi_version}"

Expand Down
26 changes: 19 additions & 7 deletions apron/src/main/java/modloader/ModLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ public class ModLoader {
static final ApronApi APRON = ApronApi.getInstance();

@Environment(EnvType.CLIENT)
private static final List<TextureBinder> ANIM_LIST = new LinkedList<>();
private static List<TextureBinder> ANIM_LIST;
@Environment(EnvType.CLIENT)
private static final Map<Integer, BaseMod> BLOCK_MODELS = new HashMap<>();
private static Map<Integer, BaseMod> BLOCK_MODELS;
@Environment(EnvType.CLIENT)
private static final Map<Integer, Boolean> BLOCK_SPECIAL_INV = new HashMap<>();
private static Map<Integer, Boolean> BLOCK_SPECIAL_INV;
private static final File CONFIG_DIR = FabricLoader.getInstance().getConfigDir().toFile();
private static final File CONFIG_FILE = new File(CONFIG_DIR, "ModLoader.cfg");
public static Level cfgLoggingLevel = Level.FINER;
Expand All @@ -118,11 +118,11 @@ public class ModLoader {
private static int highestEntityId = 3000;
private static final Map<BaseMod, Boolean> inGameHooks = new HashMap<>();
@Environment(EnvType.CLIENT)
private static final Map<BaseMod, Boolean> inGUIHooks = new HashMap<>();
private static Map<BaseMod, Boolean> inGUIHooks;
private static int itemSpriteIndex = 0;
private static int itemSpritesLeft = 0;
@Environment(EnvType.CLIENT)
private static final Map<BaseMod, Map<KeyBinding, boolean[]>> keyList = new HashMap<>();
private static Map<BaseMod, Map<KeyBinding, boolean[]>> keyList;
private static final File LOG_FILE = new File(FabricLoader.getInstance().getGameDir().toFile(), "ModLoader.txt");
private static final java.util.logging.Logger MOD_LOGGER = java.util.logging.Logger.getLogger("ModLoader");
public static final Logger LOGGER = Apron.getLogger("ModLoader");
Expand All @@ -134,13 +134,25 @@ public class ModLoader {
private static int terrainSpriteIndex = 0;
private static int terrainSpritesLeft = 0;
@Environment(EnvType.CLIENT)
private static String texPack = null;
private static String texPack;
@Environment(EnvType.CLIENT)
private static boolean texturesAdded = false;
private static boolean texturesAdded;
private static final boolean[] USED_ITEM_SPRITES = new boolean[256];
private static final boolean[] USED_TERRAIN_SPRITES = new boolean[256];
public static final String VERSION = APRON.getModLoaderVersion();

static {
if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) {
ANIM_LIST = new LinkedList<>();
BLOCK_MODELS = new HashMap<>();
BLOCK_SPECIAL_INV = new HashMap<>();
inGUIHooks = new HashMap<>();
keyList = new HashMap<>();
texPack = null;
texturesAdded = false;
}
}

/**
* Used to give your achievement a readable name and description.
*
Expand Down
25 changes: 19 additions & 6 deletions apron/src/main/java/modloadermp/ModLoaderMp.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import modloader.ModLoader;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.loader.api.FabricLoader;
import org.jetbrains.annotations.NotNull;

import net.minecraft.client.Minecraft;
Expand Down Expand Up @@ -46,17 +47,29 @@ public class ModLoaderMp {
public static final String VERSION = APRON.getModLoaderMPVersion();
private static boolean hasInit = false;
@Environment(EnvType.CLIENT)
private static boolean packet230Received = false;
private static boolean packet230Received;
@Environment(EnvType.CLIENT)
private static final Map<Integer, NetClientHandlerEntity> NET_CLIENT_HANDLER_MAP = new HashMap<>();
private static Map<Integer, NetClientHandlerEntity> NET_CLIENT_HANDLER_MAP;
@Environment(EnvType.CLIENT)
private static final Map<Integer, BaseModMp> GUI_MOD_MAP = new HashMap<>();
private static Map<Integer, BaseModMp> GUI_MOD_MAP;
@Environment(EnvType.SERVER)
private static final Map<Class<? extends Entity>, AbstractMap.SimpleEntry<Integer, Integer>> entityTrackerMap = new HashMap<>();
private static Map<Class<? extends Entity>, AbstractMap.SimpleEntry<Integer, Integer>> entityTrackerMap;
@Environment(EnvType.SERVER)
private static final Map<Class<? extends Entity>, EntityTrackerEntry> entityTrackerEntryMap = new HashMap<>();
private static Map<Class<? extends Entity>, EntityTrackerEntry> entityTrackerEntryMap;
@Environment(EnvType.SERVER)
private static final List<String> bannedMods = new ArrayList<>();
private static List<String> bannedMods;

static {
if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) {
packet230Received = false;
NET_CLIENT_HANDLER_MAP = new HashMap<>();
GUI_MOD_MAP = new HashMap<>();
} else {
entityTrackerMap = new HashMap<>();
entityTrackerEntryMap = new HashMap<>();
bannedMods = new ArrayList<>();
}
}

@Environment(EnvType.CLIENT)
public static void Init() {
Expand Down
9 changes: 8 additions & 1 deletion apron/src/main/java/modloadermp/ModLoaderPacket.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;

import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.network.PacketHandler;
import net.minecraft.packet.AbstractPacket;
import net.minecraft.server.entity.player.ServerPlayerEntity;
Expand All @@ -28,7 +29,13 @@ public class ModLoaderPacket extends AbstractPacket {
public float[] dataFloat = new float[0];
public String[] dataString = new String[0];
@Environment(EnvType.SERVER)
private static final Map<PacketHandler, ServerPlayerEntity> playerMap = new HashMap<>();
private static Map<PacketHandler, ServerPlayerEntity> playerMap;

static {
if (FabricLoader.getInstance().getEnvironmentType() == EnvType.SERVER) {
playerMap = new HashMap<>();
}
}

public ModLoaderPacket() {
}
Expand Down

0 comments on commit 19c4f45

Please sign in to comment.