Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

Commit 2d2cc76

Browse files
authored
Add classes and fields to ForgeHooks, which might be use by hacky mods (#161)
1 parent f76e5db commit 2d2cc76

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

patchwork-god-classes/src/main/java/net/minecraftforge/common/ForgeHooks.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,16 @@ public static boolean onPlayerAttackTarget(PlayerEntity player, Entity target) {
105105
return EntityEvents.attackEntity(player, target);
106106
}
107107

108+
@SuppressWarnings({ "rawtypes", "unused" })
109+
private static ThreadLocal<?> lootContext = LootHooks.lootContext;
110+
111+
// Need to have the class here to make some mod hacks work
112+
public static class LootTableContext extends LootHooks.LootTableContext {
113+
private LootTableContext(Identifier name, boolean custom) {
114+
super(name, custom);
115+
}
116+
}
117+
108118
@Nullable
109119
public static LootTable loadLootTable(Gson gson, Identifier name, JsonObject data, boolean custom, LootManager lootTableManager) {
110120
return LootHooks.loadLootTable(gson, name, data, custom, lootTableManager);

patchwork-loot/src/main/java/net/patchworkmc/impl/loot/LootHooks.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import com.google.gson.JsonElement;
3131
import com.google.gson.JsonObject;
3232
import com.google.gson.JsonParseException;
33-
import org.spongepowered.asm.mixin.Unique;
3433

3534
import net.minecraft.loot.LootManager;
3635
import net.minecraft.loot.LootTable;
@@ -41,8 +40,8 @@
4140

4241
// NOTE: this class is more or less a direct copy of parts of Forge's ForgeHooks.
4342
public class LootHooks {
44-
@Unique
45-
private static ThreadLocal<Deque<LootTableContext>> lootContext = new ThreadLocal<Deque<LootTableContext>>();
43+
// Made public for Patchwork's own use
44+
public static ThreadLocal<Deque<LootTableContext>> lootContext = new ThreadLocal<Deque<LootTableContext>>();
4645

4746
public static LootTable loadLootTable(Gson gson, Identifier name, JsonElement data, boolean custom, LootManager lootTableManager) {
4847
Deque<LootTableContext> que = lootContext.get();
@@ -105,15 +104,16 @@ public static String readPoolName(JsonObject json) {
105104
return ctx.poolCount == 1 ? "main" : "pool" + (ctx.poolCount - 1);
106105
}
107106

108-
private static class LootTableContext {
107+
// Made public for Patchwork's own use
108+
public static class LootTableContext {
109109
public final Identifier name;
110110
public final boolean custom;
111111
private final boolean vanilla;
112112
public int poolCount = 0;
113113
public int entryCount = 0;
114114
private HashSet<String> entryNames = Sets.newHashSet();
115115

116-
private LootTableContext(Identifier name, boolean custom) {
116+
protected LootTableContext(Identifier name, boolean custom) {
117117
this.name = name;
118118
this.custom = custom;
119119
this.vanilla = "minecraft".equals(this.name.getNamespace());

0 commit comments

Comments
 (0)