Skip to content

Commit

Permalink
Fixed #235
Browse files Browse the repository at this point in the history
  • Loading branch information
DisasterMoo committed Aug 9, 2019
1 parent 31a8b1e commit 50c6e00
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/java/net/dries007/tfc/ConfigTFC.java
Expand Up @@ -55,6 +55,10 @@ public static class GeneralCFG
@Config.LangKey("config." + MOD_ID + ".general.removeVanillaRecipes")
public boolean removeVanillaRecipes = true;

@Config.Comment("Enable/Disable the vanilla loot entries that conflict with TFC (ie: potatoes). False = Those loot entries are left in place.")
@Config.LangKey("config." + MOD_ID + ".general.removeVanillaLoots")
public boolean removeVanillaLoots = true;

@Config.Comment("Normal leaf drop chance for sticks")
@Config.RangeDouble(min = 0, max = 1)
@Config.LangKey("config." + MOD_ID + ".general.leafStickDropChance")
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/net/dries007/tfc/TerraFirmaCraft.java
Expand Up @@ -32,6 +32,7 @@
import net.dries007.tfc.client.render.animal.RenderAnimalTFCFamiliarity;
import net.dries007.tfc.command.*;
import net.dries007.tfc.network.*;
import net.dries007.tfc.objects.LootTablesTFC;
import net.dries007.tfc.objects.entity.EntitiesTFC;
import net.dries007.tfc.objects.items.ItemsTFC;
import net.dries007.tfc.proxy.IProxy;
Expand Down Expand Up @@ -181,6 +182,7 @@ public void init(FMLInitializationEvent event)
GuiIngameForge.renderArmor = false;
GuiIngameForge.renderExperiance = false;
}
MinecraftForge.EVENT_BUS.register(LootTablesTFC.getInstance()); //Register removal loot entries in init so it won't crash

worldTypeTFC = new WorldTypeTFC();
GameRegistry.registerWorldGenerator(new RarityBasedWorldGen(x -> x.lavaFissureRarity, new WorldGenFissure(true)), 0);
Expand Down
29 changes: 29 additions & 0 deletions src/main/java/net/dries007/tfc/objects/LootTablesTFC.java
Expand Up @@ -6,7 +6,12 @@
package net.dries007.tfc.objects;

import net.minecraft.util.ResourceLocation;
import net.minecraft.world.storage.loot.LootPool;
import net.minecraft.world.storage.loot.LootTableList;
import net.minecraftforge.event.LootTableLoadEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

import net.dries007.tfc.ConfigTFC;

import static net.dries007.tfc.api.util.TFCConstants.MOD_ID;

Expand All @@ -26,4 +31,28 @@ private static ResourceLocation register(String id)
{
return LootTableList.register(new ResourceLocation(MOD_ID, id));
}

private static final LootTablesTFC INSTANCE = new LootTablesTFC();

public static LootTablesTFC getInstance() { return INSTANCE; }

@SubscribeEvent
public void onLootTableLoad(LootTableLoadEvent event)
{
LootPool pool = event.getTable().getPool("main");
//noinspection ConstantConditions - it can be null on non-vanilla pools
if (ConfigTFC.GENERAL.removeVanillaLoots && pool != null)
{
pool.removeEntry("minecraft:potato");
pool.removeEntry("minecraft:carrot");
pool.removeEntry("minecraft:wheat");
pool.removeEntry("minecraft:gold_nugget");
pool.removeEntry("minecraft:gold_ingot");
pool.removeEntry("minecraft:iron_ingot");
pool.removeEntry("minecraft:iron_nugget");
pool.removeEntry("minecraft:leather");
pool.removeEntry("minecraft:coal");
pool.removeEntry("minecraft:diamond");
}
}
}

0 comments on commit 50c6e00

Please sign in to comment.