Chest Loot Event

Started by XMagoManco on

Topic category: Advanced modding

Joined May 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Chest Loot Event

I am trying to add a chest loot event (ie, add the generation of a modded item or block into natural generated chests of, for example, dugeons).

I know the code for make it in normal mods (more down), but it does not works on mcreator (or I don't know how to make work it on mcreator). It is translated into a recompile fail. Can somebody help me?

Joined Aug 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
First we need see your code +
Mon, 09/19/2016 - 14:30

First we need see your code + console log/error , else it is very hard to say anything

Joined May 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
package mod.mcreator;
Mon, 09/19/2016 - 17:31

package mod.mcreator;

import mod.mcreator.SHItems;
import mod.mcreator.reference.Reference;
import net.minecraft.item.Item;
import net.minecraft.world.storage.loot.LootEntryItem;
import net.minecraft.world.storage.loot.LootPool;
import net.minecraft.world.storage.loot.LootTableList;
import net.minecraft.world.storage.loot.conditions.LootCondition;
import net.minecraft.world.storage.loot.functions.LootFunction;
import net.minecraftforge.event.LootTableLoadEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

public class LootEventHandler
{
private void addLoot(LootPool pool, Item item, int weight)
{
pool.addEntry(new LootEntryItem(item, weight, 0, new LootFunction[0], new LootCondition[0], Reference.MOD_ID + item.getUnlocalizedName()));
}

@SubscribeEvent
public void onLootLoad(LootTableLoadEvent event)
{
if(event.getName().equals(LootTableList.CHESTS_NETHER_BRIDGE))
{
LootPool pool = event.getTable().getPool("main");
addLoot(pool, mod.mcreator_AmbrosiaFood, 1);
}
else if(event.getName().equals(LootTableList.CHESTS_END_CITY))
{
addLoot(event.getTable().getPool("main"), mod.mcreator_FoodAmbrosia, 1);
addLoot(event.getTable().getPool("main"), mod.mcreator_FoodRawDragonMeat, 1);
}
}
}

Joined May 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I written bad the import part
Mon, 09/19/2016 - 17:34

I written bad the import part before. This is:

 

package mod.mcreator;

import mod.mcreator.mod_mcreator;
import mod.mcreator.reference.Reference;
import net.minecraft.item.Item;
import net.minecraft.world.storage.loot.LootEntryItem;
import net.minecraft.world.storage.loot.LootPool;
import net.minecraft.world.storage.loot.LootTableList;
import net.minecraft.world.storage.loot.conditions.LootCondition;
import net.minecraft.world.storage.loot.functions.LootFunction;
import net.minecraftforge.event.LootTableLoadEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

 

Joined Aug 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
If this is full code problem
Mon, 09/19/2016 - 18:37

If this is full code problem should be, that in case that you made the class in the way that you made some MCreator element and edited code , you must have your class as a inner class of the mcreator_SOMETHING + you need keep some the mcreator methods. also I do not see where you have registred the handler . anyway is possible that problem is differet , but I do not know your error