mirror of
https://github.com/GTNewHorizons/MagicBees.git
synced 2026-11-27 15:33:15 +00:00
Adding Manasteel Grafter & Scoop.
Extrated grafter superclass from Thaumium Grafter so manasteel version can also do the thing with Thaumcraft trees.
This commit is contained in:
1 parent
319682ae2b
commit
61fdd7ad09
9 files changed
+211
-56
No files matched your search
@@ -0,0 +1,61 @@
|
||||
package magicbees.item;
|
||||
|
||||
import magicbees.main.Config;
|
||||
import magicbees.main.utils.compat.ThaumcraftHelper;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import forestry.api.arboriculture.IToolGrafter;
|
||||
|
||||
public class ItemGrafter extends Item implements IToolGrafter {
|
||||
|
||||
public ItemGrafter() {
|
||||
super();
|
||||
this.setMaxStackSize(1);
|
||||
this.setCreativeTab(forestry.api.core.Tabs.tabArboriculture);
|
||||
this.setHarvestLevel("grafter", 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getSaplingModifier(ItemStack stack, World world, EntityPlayer player, int x, int y, int z) {
|
||||
return 100f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockDestroyed(ItemStack itemstack, World world, Block block, int x, int y, int z, EntityLivingBase entityLiving) {
|
||||
int damage = 1;
|
||||
if (ThaumcraftHelper.isActive()) {
|
||||
if (block == Config.tcLeaf)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z) & 1;
|
||||
if (meta == 0 || meta == 1)
|
||||
{
|
||||
double chance = Math.random();
|
||||
if (chance <= Config.thaumcraftSaplingDroprate)
|
||||
{
|
||||
this.dropItem(world, x, y, z, new ItemStack(Config.tcPlant, 1, meta));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
itemstack.damageItem(damage, entityLiving);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void dropItem(World world, int x, int y, int z, ItemStack item) {
|
||||
if (!world.isRemote && world.getGameRules().getGameRuleBooleanValue("doTileDrops")) {
|
||||
float f = 0.7F;
|
||||
double d0 = (double)(world.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
|
||||
double d1 = (double)(world.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
|
||||
double d2 = (double)(world.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
|
||||
EntityItem entityitem = new EntityItem(world, (double)x + d0, (double)y + d1, (double)z + d2, item);
|
||||
entityitem.delayBeforeCanPickup = 10;
|
||||
world.spawnEntityInWorld(entityitem);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package magicbees.item;
|
||||
|
||||
import magicbees.main.CommonProxy;
|
||||
import magicbees.main.utils.compat.BotaniaHelper;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.api.mana.IManaUsingItem;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@Optional.InterfaceList({
|
||||
@Optional.Interface(iface = "vazkii.botania.api.mana.IManaUsingItem", modid = BotaniaHelper.Name, striprefs = true)
|
||||
})
|
||||
public class ItemManasteelGrafter extends ItemGrafter implements IManaUsingItem {
|
||||
|
||||
public static final int MANA_PER_DAMAGE = 90;
|
||||
|
||||
public ItemManasteelGrafter() {
|
||||
super();
|
||||
this.setMaxDamage(15);
|
||||
this.setUnlocalizedName("manasteelGrafter");
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = BotaniaHelper.Name)
|
||||
public boolean getIsRepairable(ItemStack toolStack, ItemStack material) {
|
||||
return (material.getItem() == BotaniaHelper.itemManaResource && material.getItemDamage() == BotaniaHelper.ManaResource.MANASTEEL.ordinal()) || super.getIsRepairable(toolStack, material);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister) {
|
||||
this.itemIcon = iconRegister.registerIcon(CommonProxy.DOMAIN + ":manasteelGrafter");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5) {
|
||||
// Unsure if the server-side exclusion is necessary, but boy it looks disconcerting on the client if it's in.
|
||||
if (/*!world.isRemote && */stack.getItemDamage() > 0 && player instanceof EntityPlayer) {
|
||||
if (BotaniaHelper.requestMana(stack, (EntityPlayer)player, MANA_PER_DAMAGE, 1)) {
|
||||
stack.setItemDamage(stack.getItemDamage() - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean usesMana(ItemStack arg0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package magicbees.item;
|
||||
|
||||
import magicbees.main.CommonProxy;
|
||||
import magicbees.main.utils.compat.BotaniaHelper;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.api.mana.IManaUsingItem;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import forestry.api.core.IToolScoop;
|
||||
|
||||
@Optional.InterfaceList({
|
||||
@Optional.Interface(iface = "vazkii.botania.api.mana.IManaUsingItem", modid = BotaniaHelper.Name, striprefs = true)
|
||||
})
|
||||
public class ItemManasteelScoop extends Item implements IManaUsingItem, IToolScoop {
|
||||
|
||||
public static final int MANA_PER_DAMAGE = 30;
|
||||
|
||||
public ItemManasteelScoop() {
|
||||
super();
|
||||
this.maxStackSize = 1;
|
||||
this.setMaxDamage(20);
|
||||
this.setCreativeTab(forestry.api.core.Tabs.tabApiculture);
|
||||
this.setUnlocalizedName("manasteelScoop");
|
||||
this.setHarvestLevel("scoop", 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int x, int y, int z, EntityLivingBase player) {
|
||||
stack.damageItem(1, player);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean usesMana(ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = BotaniaHelper.Name)
|
||||
public boolean getIsRepairable(ItemStack toolStack, ItemStack material) {
|
||||
return (material.getItem() == BotaniaHelper.itemManaResource && material.getItemDamage() == BotaniaHelper.ManaResource.MANASTEEL.ordinal()) || super.getIsRepairable(toolStack, material);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister) {
|
||||
this.itemIcon = iconRegister.registerIcon(CommonProxy.DOMAIN + ":manasteelScoop");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5) {
|
||||
// Unsure if the server-side exclusion is necessary, but boy it looks disconcerting on the client if it's in.
|
||||
if (/*!world.isRemote && */stack.getItemDamage() > 0 && player instanceof EntityPlayer) {
|
||||
if (BotaniaHelper.requestMana(stack, (EntityPlayer)player, MANA_PER_DAMAGE, 1)) {
|
||||
stack.setItemDamage(stack.getItemDamage() - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,47 +1,30 @@
|
||||
package magicbees.item;
|
||||
|
||||
import magicbees.main.CommonProxy;
|
||||
import magicbees.main.Config;
|
||||
import magicbees.main.utils.compat.ThaumcraftHelper;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
import thaumcraft.api.IRepairableExtended;
|
||||
import thaumcraft.api.ThaumcraftApi;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import forestry.api.arboriculture.IToolGrafter;
|
||||
|
||||
@Optional.InterfaceList(
|
||||
{
|
||||
@Optional.InterfaceList({
|
||||
@Optional.Interface(iface = "thaumcraft.api.IRepairableExtended", modid = ThaumcraftHelper.Name, striprefs = true)
|
||||
}
|
||||
)
|
||||
public class ItemThaumiumGrafter extends Item implements IRepairableExtended, IToolGrafter
|
||||
})
|
||||
public class ItemThaumiumGrafter extends ItemGrafter implements IRepairableExtended
|
||||
{
|
||||
public ItemThaumiumGrafter()
|
||||
{
|
||||
super();
|
||||
this.setMaxStackSize(1);
|
||||
this.setMaxDamage(15);
|
||||
this.setCreativeTab(forestry.api.core.Tabs.tabArboriculture);
|
||||
this.setUnlocalizedName("thaumiumGrafter");
|
||||
this.setHarvestLevel("grafter", 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getSaplingModifier(ItemStack stack, World world, EntityPlayer player, int x, int y, int z)
|
||||
{
|
||||
return 100f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float func_150893_a(ItemStack itemStack, Block block)
|
||||
{
|
||||
@@ -53,41 +36,6 @@ public class ItemThaumiumGrafter extends Item implements IRepairableExtended, IT
|
||||
{
|
||||
return ForgeHooks.isToolEffective(itemStack, block, metadata) ? 4.8f : func_150893_a(itemStack, block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockDestroyed(ItemStack itemstack, World world, Block block, int x, int y, int z,
|
||||
EntityLivingBase entityLiving)
|
||||
{
|
||||
int damage = 1;
|
||||
if (block == Config.tcLeaf)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z) & 1;
|
||||
if (meta == 0 || meta == 1)
|
||||
{
|
||||
double chance = Math.random();
|
||||
if (chance <= Config.thaumcraftSaplingDroprate)
|
||||
{
|
||||
this.dropItem(world, x, y, z, new ItemStack(Config.tcPlant, 1, meta));
|
||||
}
|
||||
}
|
||||
}
|
||||
itemstack.damageItem(damage, entityLiving);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void dropItem(World world, int x, int y, int z, ItemStack item)
|
||||
{
|
||||
if (!world.isRemote && world.getGameRules().getGameRuleBooleanValue("doTileDrops"))
|
||||
{
|
||||
float f = 0.7F;
|
||||
double d0 = (double)(world.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
|
||||
double d1 = (double)(world.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
|
||||
double d2 = (double)(world.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
|
||||
EntityItem entityitem = new EntityItem(world, (double)x + d0, (double)y + d1, (double)z + d2, item);
|
||||
entityitem.delayBeforeCanPickup = 10;
|
||||
world.spawnEntityInWorld(entityitem);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the enchantability factor of the item, most of the time is based on material.
|
||||
|
||||
@@ -16,6 +16,8 @@ import magicbees.item.ItemCrystalAspect;
|
||||
import magicbees.item.ItemDrop;
|
||||
import magicbees.item.ItemMagicHive;
|
||||
import magicbees.item.ItemMagicHiveFrame;
|
||||
import magicbees.item.ItemManasteelGrafter;
|
||||
import magicbees.item.ItemManasteelScoop;
|
||||
import magicbees.item.ItemMiscResources;
|
||||
import magicbees.item.ItemMoonDial;
|
||||
import magicbees.item.ItemMysteriousMagnet;
|
||||
@@ -111,7 +113,9 @@ public class Config
|
||||
public static ItemCrystalAspect solidFlux;
|
||||
public static ItemMiscResources miscResources;
|
||||
public static ItemFood jellyBaby;
|
||||
public static Item manasteelScoop;
|
||||
public static Item thaumiumScoop;
|
||||
public static Item manasteelGrafter;
|
||||
public static Item thaumiumGrafter;
|
||||
public static ItemNugget nuggets;
|
||||
public static ItemMoonDial moonDial;
|
||||
@@ -270,7 +274,8 @@ public class Config
|
||||
magicCapsule = new ItemCapsule(CapsuleType.MAGIC, capsuleStackSizeMax);
|
||||
pollen = new ItemPollen();
|
||||
|
||||
setupThaumcraftItems();
|
||||
setupThaumcraftItems();
|
||||
setupBotaniaItems();
|
||||
setupFrames();
|
||||
setupJellyBaby();
|
||||
voidCapsule = new ItemCapsule(CapsuleType.VOID, capsuleStackSizeMax);
|
||||
@@ -488,6 +493,16 @@ public class Config
|
||||
OreDictionary.registerOre("shardApatite", nuggets.getStackForType(NuggetType.APATITE));
|
||||
}
|
||||
|
||||
private void setupBotaniaItems() {
|
||||
if (BotaniaHelper.isActive()) {
|
||||
manasteelScoop = new ItemManasteelScoop();
|
||||
GameRegistry.registerItem(manasteelScoop, manasteelScoop.getUnlocalizedName(), CommonProxy.DOMAIN);
|
||||
|
||||
manasteelGrafter = new ItemManasteelGrafter();
|
||||
GameRegistry.registerItem(manasteelGrafter, manasteelGrafter.getUnlocalizedName(), CommonProxy.DOMAIN);
|
||||
}
|
||||
}
|
||||
|
||||
private void setupThaumcraftBackpacks() {
|
||||
if (ThaumcraftHelper.isActive() && thaumaturgeBackpackActive) {
|
||||
try {
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
package magicbees.main.utils.compat;
|
||||
|
||||
import vazkii.botania.api.mana.ManaItemHandler;
|
||||
import magicbees.bees.BeeManager;
|
||||
import magicbees.main.Config;
|
||||
import magicbees.main.utils.BlockInterface;
|
||||
import magicbees.main.utils.ItemInterface;
|
||||
import magicbees.main.utils.compat.botania.BotaniaAPIDistanceHelper;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.common.config.Property;
|
||||
@@ -114,4 +117,8 @@ public class BotaniaHelper {
|
||||
p.comment = "Rate at which the Hiveacynth will spawn a Princess instead of a Drone. Default: 0.09. Setting to 0 will disable.";
|
||||
hiveacynthPrincessSpawnRate = p.getDouble();
|
||||
}
|
||||
|
||||
public static boolean requestMana(ItemStack stack, EntityPlayer player, int manaPerDamage, int charges) {
|
||||
return ManaItemHandler.requestManaExactForTool(stack, player, manaPerDamage * charges, true);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user