Started Tweaks module: Remove Flint Drop and add Flint recipe

This commit is contained in:
Bernhard Bonigl committed 2014-07-30 22:48:43 +02:00
1 parent 340795b1cc
commit 499fa1a00f
4 files changed
+89

No files matched your search

@@ -18,6 +18,7 @@ import iguanaman.iguanatweakstconstruct.proxy.CommonProxy;
import iguanaman.iguanatweakstconstruct.reference.Config;
import iguanaman.iguanatweakstconstruct.reference.Reference;
import iguanaman.iguanatweakstconstruct.replacing.IguanaToolPartReplacing;
import iguanaman.iguanatweakstconstruct.tweaks.IguanaTweaks;
import iguanaman.iguanatweakstconstruct.util.HarvestLevels;
import iguanaman.iguanatweakstconstruct.util.Log;
import mantle.pulsar.config.ForgeCFG;
@@ -87,6 +88,7 @@ public class IguanaTweaksTConstruct {
pulsar.registerPulse(new IguanaHarvestLevelTweaks());
pulsar.registerPulse(new IguanaToolLeveling());
pulsar.registerPulse(new IguanaToolPartReplacing());
pulsar.registerPulse(new IguanaTweaks());
pulsar.preInit(event);
}
@@ -14,6 +14,9 @@ public class Reference {
public static final String PULSE_LEVELING = "ToolLeveling";
public static final String PULSE_HARVESTTWEAKS = "HarvestLevelTweaks";
public static final String PULSE_REPLACING = "ToolPartReplacing";
public static final String PULSE_MOBHEADS = "MobHeads";
public static final String PULSE_TWEAKS = "IguanaTweaks";
public static final String PULSE_ITEMS = "IguanaItems";
public static final String PROXY_CLIENT_CLASS = "iguanaman.iguanatweakstconstruct.proxy.ClientProxy";
public static final String PROXY_SERVER_CLASS = "iguanaman.iguanatweakstconstruct.proxy.ServerProxy";
@@ -0,0 +1,47 @@
package iguanaman.iguanatweakstconstruct.tweaks;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.registry.GameRegistry;
import iguanaman.iguanatweakstconstruct.reference.Config;
import iguanaman.iguanatweakstconstruct.reference.Reference;
import iguanaman.iguanatweakstconstruct.tweaks.handler.FlintHandler;
import iguanaman.iguanatweakstconstruct.util.Log;
import mantle.pulsar.pulse.Handler;
import mantle.pulsar.pulse.Pulse;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
/**
* Various Tweaks for Tinkers Construct and Vanilla Minecraft. See Config.
*/
@Pulse(id = Reference.PULSE_TWEAKS, description = "Various Tweaks for vanilla Minecraft and Tinker's Construct. See Config.")
public class IguanaTweaks {
@Handler
public void postInit(FMLPostInitializationEvent event)
{
FlintTweaks();
}
private void FlintTweaks()
{
if(Config.removeFlintDrop) {
Log.info("Removing Flint drops from Gravel");
MinecraftForge.EVENT_BUS.register(new FlintHandler());
}
if(Config.addFlintRecipe) {
Log.info("Adding shapeless Flint recipe from " + Config.recipeGravelPerFlint + " Gravel");
// create recipe
ItemStack[] recipe = new ItemStack[Config.recipeGravelPerFlint];
for(int i = 0; i < Config.recipeGravelPerFlint; i++)
recipe[i] = new ItemStack(Blocks.gravel);
// add recipe
GameRegistry.addShapelessRecipe(new ItemStack(Items.flint), recipe);
}
}
}
@@ -0,0 +1,37 @@
package iguanaman.iguanatweakstconstruct.tweaks.handler;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import iguanaman.iguanatweakstconstruct.reference.Config;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.event.world.BlockEvent;
import java.util.ListIterator;
public class FlintHandler {
@SubscribeEvent
public void onBlockHarvested(BlockEvent.HarvestDropsEvent event)
{
// remove flint drop
if(event.block != null && event.block == Blocks.gravel)
{
ListIterator<ItemStack> iter = event.drops.listIterator();
boolean hasGravel = false;
while(iter.hasNext())
{
Item item = iter.next().getItem();
if(item == Items.flint)
iter.remove();
else if(item == Item.getItemFromBlock(Blocks.gravel))
hasGravel = true;
}
// ensure that gravel drops
if(!hasGravel)
event.drops.add(new ItemStack(Blocks.gravel));
}
}
}