mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-19 19:59:42 +00:00
New AddReloadListenerEvent that gathers server side data reload handlers. (#6849)
This commit is contained in:
1 parent
8e5138da27
commit
ff86201523
5 files changed
+65
-23
No files matched your search
@@ -109,6 +109,8 @@ import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.data.IOptionalTagEntry;
|
||||
import net.minecraftforge.common.loot.IGlobalLootModifier;
|
||||
import net.minecraftforge.common.loot.LootModifierManager;
|
||||
import net.minecraftforge.common.util.BlockSnapshot;
|
||||
import net.minecraftforge.event.AnvilUpdateEvent;
|
||||
import net.minecraftforge.event.DifficultyChangeEvent;
|
||||
@@ -1165,12 +1167,10 @@ public class ForgeHooks
|
||||
* @return The modified list
|
||||
*/
|
||||
public static List<ItemStack> modifyLoot(List<ItemStack> list, LootContext context) {
|
||||
/*
|
||||
LootModifierManager man = context.getWorld().getServer().getLootModifierManager();
|
||||
LootModifierManager man = ForgeInternalHandler.getLootModifierManager();
|
||||
for(IGlobalLootModifier mod : man.getAllLootMods()) {
|
||||
list = mod.apply(list, context);
|
||||
}
|
||||
*/
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,9 @@ import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraftforge.common.loot.LootModifierManager;
|
||||
import net.minecraftforge.common.util.FakePlayerFactory;
|
||||
import net.minecraftforge.event.AddReloadListenerEvent;
|
||||
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
import net.minecraftforge.event.world.ChunkEvent;
|
||||
@@ -109,5 +111,21 @@ public class ForgeInternalHandler
|
||||
{
|
||||
ForgeHooks.updateBurns();
|
||||
}
|
||||
|
||||
private static LootModifierManager INSTANCE;
|
||||
|
||||
@SubscribeEvent
|
||||
public void onResourceReload(AddReloadListenerEvent event)
|
||||
{
|
||||
INSTANCE = new LootModifierManager();
|
||||
event.addListener(INSTANCE);
|
||||
}
|
||||
|
||||
static LootModifierManager getLootModifierManager()
|
||||
{
|
||||
if(INSTANCE == null)
|
||||
throw new IllegalStateException("Can not retrieve LootModifierManager until resources have loaded once.");
|
||||
return INSTANCE;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user