Register TConstruct bushes/mobs with MFR API
This commit is contained in:
parent
128457d55c
commit
f5f7cc5935
@ -0,0 +1,61 @@
|
||||
package mods.tinker.tconstruct.plugins.minefactoryreloaded;
|
||||
|
||||
import mods.tinker.tconstruct.common.TContent;
|
||||
import mods.tinker.tconstruct.entity.BlueSlime;
|
||||
import mods.tinker.tconstruct.entity.Crystal;
|
||||
import mods.tinker.tconstruct.entity.MetalSlime;
|
||||
import mods.tinker.tconstruct.entity.NitroCreeper;
|
||||
import mods.tinker.tconstruct.entity.Skyla;
|
||||
import mods.tinker.tconstruct.plugins.minefactoryreloaded.grindables.GrindableStandard;
|
||||
import mods.tinker.tconstruct.plugins.minefactoryreloaded.harvestables.HarvestableOreBerry;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.Mod.Init;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.network.NetworkMod;
|
||||
|
||||
import powercrystals.minefactoryreloaded.api.FarmingRegistry;
|
||||
|
||||
|
||||
@Mod(modid = "TConstruct|CompatMineFactoryReloaded", name = "TConstruct Compat: MFR", version = "0.1", dependencies = "after:MineFactoryReloaded;after:TConstruct")
|
||||
@NetworkMod(clientSideRequired = false, serverSideRequired = false)
|
||||
public class MineFactoryReloaded
|
||||
{
|
||||
@Init
|
||||
public static void load(FMLInitializationEvent ev)
|
||||
{
|
||||
if(!Loader.isModLoaded("MineFactoryReloaded"))
|
||||
{
|
||||
FMLLog.warning("MineFactoryReloaded missing - TConstruct Compat: MFR not loading.");
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
FMLLog.fine("MineFactoryReloaded detected. Registering TConstruct farmables/grindables with MFR's Farming Registry.");
|
||||
|
||||
FarmingRegistry.registerHarvestable(new HarvestableOreBerry(TContent.oreBerry.blockID, TContent.oreBerries.itemID, 0));
|
||||
FarmingRegistry.registerHarvestable(new HarvestableOreBerry(TContent.oreBerrySecond.blockID, TContent.oreBerries.itemID, 4));
|
||||
|
||||
// A note: in 1.6, this method of registering grindables will no longer exist, once MFR moves to a more universal way of gathering drops.
|
||||
FarmingRegistry.registerGrindable(new GrindableStandard(BlueSlime.class, new ItemStack(TContent.strangeFood)));
|
||||
FarmingRegistry.registerGrindable(new GrindableStandard(Crystal.class, new ItemStack(Item.gunpowder)));
|
||||
FarmingRegistry.registerGrindable(new GrindableStandard(MetalSlime.class, new ItemStack(TContent.strangeFood)));
|
||||
FarmingRegistry.registerGrindable(new GrindableStandard(NitroCreeper.class, new ItemStack(Item.gunpowder)));
|
||||
FarmingRegistry.registerGrindable(new GrindableStandard(Skyla.class, new ItemStack(Item.gunpowder)));
|
||||
|
||||
/*
|
||||
* Perhaps TC ores should be registered as drops from the MFR Laser Drill here, but I don't know which things would be suitable for that.
|
||||
* Syntax: FarmingRegistry.registerLaserOre(int weight, ItemStack droppedStack));
|
||||
* Currently used weights are from about 50 (emerald) to 175 (coal).
|
||||
*/
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package mods.tinker.tconstruct.plugins.minefactoryreloaded.grindables;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import powercrystals.minefactoryreloaded.api.IFactoryGrindable;
|
||||
import powercrystals.minefactoryreloaded.api.MobDrop;
|
||||
|
||||
public class GrindableStandard implements IFactoryGrindable
|
||||
{
|
||||
private Class<?> _grindableClass;
|
||||
private List<MobDrop> _drops;
|
||||
|
||||
public GrindableStandard(Class<?> entityToGrind, MobDrop[] dropStacks)
|
||||
{
|
||||
_grindableClass = entityToGrind;
|
||||
_drops = new ArrayList<MobDrop>();
|
||||
for(MobDrop d : dropStacks)
|
||||
{
|
||||
_drops.add(d);
|
||||
}
|
||||
}
|
||||
|
||||
public GrindableStandard(Class<?> entityToGrind, ItemStack dropStack)
|
||||
{
|
||||
_grindableClass = entityToGrind;
|
||||
_drops = new ArrayList<MobDrop>();
|
||||
_drops.add(new MobDrop(10, dropStack));
|
||||
}
|
||||
|
||||
public GrindableStandard(Class<?> entityToGrind)
|
||||
{
|
||||
_grindableClass = entityToGrind;
|
||||
_drops = new ArrayList<MobDrop>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getGrindableEntity()
|
||||
{
|
||||
return _grindableClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MobDrop> grind(World world, EntityLiving entity, Random random)
|
||||
{
|
||||
return _drops;
|
||||
}
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
package mods.tinker.tconstruct.plugins.minefactoryreloaded.harvestables;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import powercrystals.minefactoryreloaded.api.HarvestType;
|
||||
import powercrystals.minefactoryreloaded.api.IFactoryHarvestable;
|
||||
|
||||
public class HarvestableOreBerry implements IFactoryHarvestable
|
||||
{
|
||||
private int _sourceBlockId;
|
||||
private int _berryItemId;
|
||||
private int _metaOffset;
|
||||
|
||||
public HarvestableOreBerry(int sourceBlockId, int berryItemId, int metaOffset)
|
||||
{
|
||||
_sourceBlockId = sourceBlockId;
|
||||
_berryItemId = berryItemId;
|
||||
_metaOffset = metaOffset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPlantId()
|
||||
{
|
||||
return _sourceBlockId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HarvestType getHarvestType()
|
||||
{
|
||||
return HarvestType.Column;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean breakBlock()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHarvested(World world, Map<String, Boolean> harvesterSettings, int x, int y, int z)
|
||||
{
|
||||
return world.getBlockMetadata(x, y, z) >= 12;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(World world, Random rand, Map<String, Boolean> harvesterSettings, int x, int y, int z)
|
||||
{
|
||||
ItemStack[] returnItems = {new ItemStack(_berryItemId, 1, world.getBlockMetadata(x, y, z) % 4 + _metaOffset)};
|
||||
return Arrays.asList(returnItems);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preHarvest(World world, int x, int y, int z)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postHarvest(World world, int x, int y, int z)
|
||||
{
|
||||
world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x,y,z) - 4, 2);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user