From 34f779563eb6039665344bb6972dd2dedeb39ec7 Mon Sep 17 00:00:00 2001 From: WayofTime Date: Tue, 21 Apr 2015 12:33:20 -0400 Subject: [PATCH] Added an AgriCraft Harvest Handler for their crops (uses reflection, so will be pulled as soon as the official one is made on their side) Added the checks required for Strength to affect the damage of the Tool Paradigms. --- build.properties | 6 +- .../AlchemicalWizardry.java | 7 ++ .../api/items/ItemSpellMultiTool.java | 13 ++- .../harvest/AgriCraftCropHarvestHandler.java | 83 +++++++++++++++++++ .../harvest/BloodMagicHarvestHandler.java | 11 ++- .../common/items/armour/OmegaArmourWind.java | 4 +- .../earth/SelfEnvironmentalEarth.java | 13 +-- .../impactEffects/wind/MeleeDefaultWind.java | 6 +- .../wind/MeleeOffensiveWind.java | 6 +- .../wind/ProjectileOffensiveWind.java | 9 +- .../wind/SelfEnvironmentalWind.java | 12 +-- 11 files changed, 136 insertions(+), 34 deletions(-) create mode 100644 src/main/java/WayofTime/alchemicalWizardry/common/harvest/AgriCraftCropHarvestHandler.java diff --git a/build.properties b/build.properties index ffc4fc82..3799c1a6 100644 --- a/build.properties +++ b/build.properties @@ -1,12 +1,12 @@ # -#Thu Apr 16 16:19:02 EDT 2015 +#Mon Apr 20 14:42:19 EDT 2015 mod_name=BloodMagic forge_version=10.13.3.1374-1.7.10 ccc_version=1.0.4.29 nei_version=1.0.3.64 //=Dependency Information package_group=com.wayoftime.bloodmagic -mod_version=1.3.2 +mod_version=1.3.2aBeta minetweaker_version=Dev-1.7.10-3.0.9B mc_version=1.7.10 -build_number=2 +build_number=3 diff --git a/src/main/java/WayofTime/alchemicalWizardry/AlchemicalWizardry.java b/src/main/java/WayofTime/alchemicalWizardry/AlchemicalWizardry.java index 5357fbf5..4aae3ded 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/AlchemicalWizardry.java +++ b/src/main/java/WayofTime/alchemicalWizardry/AlchemicalWizardry.java @@ -104,6 +104,7 @@ import WayofTime.alchemicalWizardry.common.entity.mob.EntityShadeElemental; import WayofTime.alchemicalWizardry.common.entity.mob.EntitySmallEarthGolem; import WayofTime.alchemicalWizardry.common.entity.mob.EntityWaterElemental; import WayofTime.alchemicalWizardry.common.entity.mob.EntityWingedFireDemon; +import WayofTime.alchemicalWizardry.common.harvest.AgriCraftCropHarvestHandler; import WayofTime.alchemicalWizardry.common.harvest.BloodMagicHarvestHandler; import WayofTime.alchemicalWizardry.common.harvest.CactusReedHarvestHandler; import WayofTime.alchemicalWizardry.common.harvest.GourdHarvestHandler; @@ -1199,6 +1200,12 @@ public class AlchemicalWizardry AlchemicalWizardry.logger.info("Loaded MineTweaker 3 Integration"); } + if(Loader.isModLoaded("AgriCraft")) + { + HarvestRegistry.registerHarvestHandler(new AgriCraftCropHarvestHandler()); + AlchemicalWizardry.logger.info("Loaded AgriCraft Handlers!"); + } + this.isBotaniaLoaded = Loader.isModLoaded("Botania"); this.isFMPLoaded = Loader.isModLoaded("ForgeMultipart"); diff --git a/src/main/java/WayofTime/alchemicalWizardry/api/items/ItemSpellMultiTool.java b/src/main/java/WayofTime/alchemicalWizardry/api/items/ItemSpellMultiTool.java index 93ed96f5..ecce9ec1 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/api/items/ItemSpellMultiTool.java +++ b/src/main/java/WayofTime/alchemicalWizardry/api/items/ItemSpellMultiTool.java @@ -11,6 +11,7 @@ import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.Item; @@ -48,12 +49,16 @@ public class ItemSpellMultiTool extends Item { this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:BoundTool"); } - + @Override public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase) { float damage = this.getCustomItemAttack(par1ItemStack); + + float f = (float)par3EntityLivingBase.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue(); + damage *= f; + SpellParadigmTool parad = this.loadParadigmFromStack(par1ItemStack); if (parad != null) @@ -149,7 +154,7 @@ public class ItemSpellMultiTool extends Item { if (isEffective) { - if (localBlock.removedByPlayer(world, player, x, y, z)) + if (localBlock.removedByPlayer(world, player, x, y, z, true)) { localBlock.onBlockDestroyedByPlayer(world, x, y, z, localMeta); } @@ -194,8 +199,8 @@ public class ItemSpellMultiTool extends Item } } - if (!world.isRemote) - world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12)); +// if (!world.isRemote) +// world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12)); return true; } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/harvest/AgriCraftCropHarvestHandler.java b/src/main/java/WayofTime/alchemicalWizardry/common/harvest/AgriCraftCropHarvestHandler.java new file mode 100644 index 00000000..6ed664b2 --- /dev/null +++ b/src/main/java/WayofTime/alchemicalWizardry/common/harvest/AgriCraftCropHarvestHandler.java @@ -0,0 +1,83 @@ +package WayofTime.alchemicalWizardry.common.harvest; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import net.minecraft.block.Block; +import net.minecraft.world.World; +import WayofTime.alchemicalWizardry.api.harvest.IHarvestHandler; +import cpw.mods.fml.common.registry.GameRegistry; + +public class AgriCraftCropHarvestHandler implements IHarvestHandler +{ + public Block harvestBlock; + public Method isMature; + public Method harvest; + + public AgriCraftCropHarvestHandler() + { + this.harvestBlock = getBlockForString("AgriCraft:crops"); + if(this.harvestBlock != null) + { + try { + Class clazz = Class.forName("com.InfinityRaider.AgriCraft.blocks.BlockCrop"); + if(clazz != null) + { + isMature = clazz.getMethod("isMature", World.class, int.class, int.class, int.class); + harvest = clazz.getMethod("harvest", World.class, int.class, int.class, int.class); + } + } catch (ClassNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (NoSuchMethodException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (SecurityException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + public boolean isHarvesterValid() + { + return harvestBlock != null && isMature != null && harvest != null; + } + + public static Block getBlockForString(String str) + { + String[] parts = str.split(":"); + String modId = parts[0]; + String name = parts[1]; + return GameRegistry.findBlock(modId, name); + } + + public boolean canHandleBlock(Block block) + { + return block == harvestBlock; + } + + @Override + public boolean harvestAndPlant(World world, int xCoord, int yCoord, int zCoord, Block block, int meta) + { + if (!this.canHandleBlock(block)) + { + return false; + } + + try { + return (Boolean)(isMature.invoke(block, world, xCoord, yCoord, zCoord)) && (Boolean)(harvest.invoke(block, world, xCoord, yCoord, zCoord)); + } catch (IllegalAccessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalArgumentException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (InvocationTargetException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return false; + } +} diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/harvest/BloodMagicHarvestHandler.java b/src/main/java/WayofTime/alchemicalWizardry/common/harvest/BloodMagicHarvestHandler.java index f1b28c48..3b437fac 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/harvest/BloodMagicHarvestHandler.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/harvest/BloodMagicHarvestHandler.java @@ -1,7 +1,9 @@ package WayofTime.alchemicalWizardry.common.harvest; -import WayofTime.alchemicalWizardry.api.harvest.IHarvestHandler; +import java.util.List; + import net.minecraft.block.Block; +import net.minecraft.block.BlockCrops; import net.minecraft.entity.item.EntityItem; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -9,8 +11,7 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.common.IPlantable; - -import java.util.List; +import WayofTime.alchemicalWizardry.api.harvest.IHarvestHandler; public class BloodMagicHarvestHandler implements IHarvestHandler { @@ -21,6 +22,10 @@ public class BloodMagicHarvestHandler implements IHarvestHandler public int getHarvestMeta(Block block) { + if(block instanceof BlockCrops) + { + + } if (block == Blocks.wheat) { return 7; diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/armour/OmegaArmourWind.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/armour/OmegaArmourWind.java index 40f090de..77c80a7c 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/armour/OmegaArmourWind.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/armour/OmegaArmourWind.java @@ -118,11 +118,11 @@ public class OmegaArmourWind extends OmegaArmour public float getHealthBoostModifierForLevel(int yLevel) { - return 0.05f * ((((float)yLevel)/64f) * 1.5f - 1); + return 0.05f * ((((float)Math.min(yLevel, 255))/64f) * 1.5f - 1); } public float getDamageModifierForLevel(int yLevel) { - return 0.02f * ((((float)yLevel)/64f) * 1.5f - 1); + return 0.02f * ((((float)Math.min(yLevel, 255))/64f) * 1.5f - 1); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/earth/SelfEnvironmentalEarth.java b/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/earth/SelfEnvironmentalEarth.java index 2dbc12ff..d0ef0947 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/earth/SelfEnvironmentalEarth.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/earth/SelfEnvironmentalEarth.java @@ -1,15 +1,16 @@ package WayofTime.alchemicalWizardry.common.spell.complex.effect.impactEffects.earth; -import WayofTime.alchemicalWizardry.api.spell.SelfSpellEffect; -import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper; +import java.util.List; + import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.world.World; - -import java.util.List; +import WayofTime.alchemicalWizardry.api.spell.SelfSpellEffect; +import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper; public class SelfEnvironmentalEarth extends SelfSpellEffect { @@ -28,9 +29,9 @@ public class SelfEnvironmentalEarth extends SelfSpellEffect for (Entity entity : entities) { - if (entity instanceof EntityLiving) + if (entity instanceof EntityLivingBase) { - ((EntityLiving) entity).addPotionEffect(new PotionEffect(Potion.weakness.id, dur, this.potencyUpgrades)); + ((EntityLivingBase) entity).addPotionEffect(new PotionEffect(Potion.weakness.id, dur, this.potencyUpgrades)); } } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/wind/MeleeDefaultWind.java b/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/wind/MeleeDefaultWind.java index 0108b356..803acb7e 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/wind/MeleeDefaultWind.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/wind/MeleeDefaultWind.java @@ -1,10 +1,10 @@ package WayofTime.alchemicalWizardry.common.spell.complex.effect.impactEffects.wind; -import WayofTime.alchemicalWizardry.api.spell.ExtrapolatedMeleeEntityEffect; import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; +import WayofTime.alchemicalWizardry.api.spell.ExtrapolatedMeleeEntityEffect; public class MeleeDefaultWind extends ExtrapolatedMeleeEntityEffect { @@ -21,7 +21,7 @@ public class MeleeDefaultWind extends ExtrapolatedMeleeEntityEffect { double wantedVel = -(0.5d + 0.7d * this.powerUpgrades); - if (entity instanceof EntityLiving) + if (entity instanceof EntityLivingBase) { double dist = Math.sqrt(entity.getDistanceToEntity(player)); double xVel = wantedVel * (entity.posX - player.posX) / dist; diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/wind/MeleeOffensiveWind.java b/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/wind/MeleeOffensiveWind.java index 8e2b32f5..8dd15f71 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/wind/MeleeOffensiveWind.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/wind/MeleeOffensiveWind.java @@ -1,10 +1,10 @@ package WayofTime.alchemicalWizardry.common.spell.complex.effect.impactEffects.wind; -import WayofTime.alchemicalWizardry.api.spell.ExtrapolatedMeleeEntityEffect; import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; +import WayofTime.alchemicalWizardry.api.spell.ExtrapolatedMeleeEntityEffect; public class MeleeOffensiveWind extends ExtrapolatedMeleeEntityEffect { @@ -21,7 +21,7 @@ public class MeleeOffensiveWind extends ExtrapolatedMeleeEntityEffect { double wantedVel = 1.0d + 1.0d * this.powerUpgrades; - if (entity instanceof EntityLiving) + if (entity instanceof EntityLivingBase) { double dist = Math.sqrt(entity.getDistanceToEntity(player)); double xVel = wantedVel * (entity.posX - player.posX) / dist; diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/wind/ProjectileOffensiveWind.java b/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/wind/ProjectileOffensiveWind.java index 77da2d79..372e8243 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/wind/ProjectileOffensiveWind.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/wind/ProjectileOffensiveWind.java @@ -1,12 +1,13 @@ package WayofTime.alchemicalWizardry.common.spell.complex.effect.impactEffects.wind; -import WayofTime.alchemicalWizardry.AlchemicalWizardry; -import WayofTime.alchemicalWizardry.api.spell.ProjectileImpactEffect; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.potion.PotionEffect; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; +import WayofTime.alchemicalWizardry.AlchemicalWizardry; +import WayofTime.alchemicalWizardry.api.spell.ProjectileImpactEffect; public class ProjectileOffensiveWind extends ProjectileImpactEffect { @@ -19,9 +20,9 @@ public class ProjectileOffensiveWind extends ProjectileImpactEffect @Override public void onEntityImpact(Entity mop, Entity proj) { - if (mop instanceof EntityLiving) + if (mop instanceof EntityLivingBase) { - ((EntityLiving) mop).addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionHeavyHeart.id, (int) (100 * (2 * this.powerUpgrades + 1) * (1 / (this.potencyUpgrades + 1))), this.potencyUpgrades)); + ((EntityLivingBase) mop).addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionHeavyHeart.id, (int) (100 * (2 * this.powerUpgrades + 1) * (1 / (this.potencyUpgrades + 1))), this.potencyUpgrades)); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/wind/SelfEnvironmentalWind.java b/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/wind/SelfEnvironmentalWind.java index 351371c6..efbe60ea 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/wind/SelfEnvironmentalWind.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/wind/SelfEnvironmentalWind.java @@ -1,13 +1,13 @@ package WayofTime.alchemicalWizardry.common.spell.complex.effect.impactEffects.wind; -import WayofTime.alchemicalWizardry.api.spell.SelfSpellEffect; -import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper; +import java.util.List; + import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; - -import java.util.List; +import WayofTime.alchemicalWizardry.api.spell.SelfSpellEffect; +import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper; public class SelfEnvironmentalWind extends SelfSpellEffect { @@ -29,7 +29,7 @@ public class SelfEnvironmentalWind extends SelfSpellEffect for (Entity entity : entities) { - if ((!entity.equals(player)) && entity instanceof EntityLiving) + if ((!entity.equals(player)) && entity instanceof EntityLivingBase) { double dist = Math.sqrt(entity.getDistanceToEntity(player)); double xVel = wantedVel * (entity.posX - posX) / dist;