mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-24 05:54:41 +00:00
New LootTable interaction system and event.
Modders can now modify and reference internal elements of a loot table by name. Editing can ONLY be done in the event and any external editing will cause a exception to be thrown. See this gist for more information: https://gist.github.com/LexManos/77c983d67b9ad27010428478b66d50fd
This commit is contained in:
1 parent
babd54bb87
commit
aaa146c10d
14 files changed
+627
No files matched your search
@@ -24,6 +24,7 @@ import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -39,6 +40,7 @@ import net.minecraft.world.chunk.ChunkPrimer;
|
||||
import net.minecraft.world.chunk.IChunkGenerator;
|
||||
import net.minecraft.world.storage.IPlayerFileData;
|
||||
import net.minecraft.world.storage.SaveHandler;
|
||||
import net.minecraft.world.storage.loot.LootTable;
|
||||
import net.minecraftforge.client.event.ClientChatReceivedEvent;
|
||||
import net.minecraftforge.client.event.RenderBlockOverlayEvent;
|
||||
import net.minecraftforge.client.event.RenderBlockOverlayEvent.OverlayType;
|
||||
@@ -541,4 +543,12 @@ public class ForgeEventFactory
|
||||
MinecraftForge.EVENT_BUS.post(pre ? new PopulateChunkEvent.Pre(gen, world, rand, x, z, hasVillageGenerated) : new PopulateChunkEvent.Post(gen, world, rand, x, z, hasVillageGenerated));
|
||||
}
|
||||
|
||||
public static LootTable loadLootTable(ResourceLocation name, LootTable table)
|
||||
{
|
||||
LootTableLoadEvent event = new LootTableLoadEvent(name, table);
|
||||
if (MinecraftForge.EVENT_BUS.post(event))
|
||||
return LootTable.EMPTY_LOOT_TABLE;
|
||||
return event.getTable();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package net.minecraftforge.event;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.storage.loot.LootTable;
|
||||
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
/**
|
||||
* Event fired when a LootTable json is loaded from json.
|
||||
* This event is fired whenever resources are loaded, or when the server starts.
|
||||
* This event will NOT be fired for LootTables loaded from the world folder, these are
|
||||
* considered configurations files and should not be modified by mods.
|
||||
*
|
||||
* Canceling the event will make it load a empty loot table.
|
||||
*
|
||||
*/
|
||||
@Cancelable
|
||||
public class LootTableLoadEvent extends Event
|
||||
{
|
||||
private final ResourceLocation name;
|
||||
private LootTable table;
|
||||
|
||||
public LootTableLoadEvent(ResourceLocation name, LootTable table)
|
||||
{
|
||||
this.name = name;
|
||||
this.table = table;
|
||||
}
|
||||
|
||||
public ResourceLocation getName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public LootTable getTable()
|
||||
{
|
||||
return this.table;
|
||||
}
|
||||
|
||||
public void setTable(LootTable table)
|
||||
{
|
||||
this.table = table;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user