From 12f3d5c6e005295e2e78c67e9ef2c2929526524b Mon Sep 17 00:00:00 2001 From: WayofTime Date: Mon, 11 Jul 2016 16:47:27 -0400 Subject: [PATCH] Mild work on Crushing :P --- .../bloodmagic/ritual/RitualCrushing.java | 41 +++++++++++++++---- .../assets/bloodmagic/lang/en_US.lang | 1 - 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualCrushing.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualCrushing.java index ebbd8562..b472c059 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualCrushing.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualCrushing.java @@ -11,13 +11,15 @@ import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.api.saving.SoulNetwork; import WayofTime.bloodmagic.api.ritual.AreaDescriptor; import WayofTime.bloodmagic.api.ritual.EnumRuneType; import WayofTime.bloodmagic.api.ritual.IMasterRitualStone; import WayofTime.bloodmagic.api.ritual.Ritual; import WayofTime.bloodmagic.api.ritual.RitualComponent; +import WayofTime.bloodmagic.api.saving.SoulNetwork; +import WayofTime.bloodmagic.api.soul.EnumDemonWillType; import WayofTime.bloodmagic.api.util.helper.NetworkHelper; +import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler; import WayofTime.bloodmagic.registry.ModBlocks; import WayofTime.bloodmagic.util.Utils; @@ -26,6 +28,9 @@ public class RitualCrushing extends Ritual public static final String CRUSHING_RANGE = "crushingRange"; public static final String CHEST_RANGE = "chest"; + public static double rawWillDrain = 0.5; + public static double steadfastWillDrain = 0.5; + public RitualCrushing() { super("ritualCrushing", 0, 5000, "ritual." + Constants.Mod.MODID + ".crushingRitual"); @@ -49,13 +54,18 @@ public class RitualCrushing extends Ritual return; } - TileEntity tile = world.getTileEntity(masterRitualStone.getBlockPos().up()); + BlockPos pos = masterRitualStone.getBlockPos(); + TileEntity tile = world.getTileEntity(pos.up()); + + List willConfig = masterRitualStone.getActiveWillConfig(); + + double steadfastWill = willConfig.contains(EnumDemonWillType.STEADFAST) ? WorldDemonWillHandler.getCurrentWill(world, pos, EnumDemonWillType.STEADFAST) : 0; + + boolean isSilkTouch = steadfastWill >= steadfastWillDrain; - boolean isSilkTouch = false; int fortune = 0; AreaDescriptor crushingRange = getBlockRange(CRUSHING_RANGE); - BlockPos pos = masterRitualStone.getBlockPos(); for (BlockPos newPos : crushingRange.getContainedPositions(pos)) { @@ -73,16 +83,29 @@ public class RitualCrushing extends Ritual if (isSilkTouch && block.canSilkHarvest(world, newPos, state, null)) { - int meta = block.getMetaFromState(state); - ItemStack item = new ItemStack(block, 1, meta); - ItemStack copyStack = ItemStack.copyItemStack(item); + ItemStack checkStack = block.getItem(world, newPos, state); + if (checkStack == null) + { + continue; + } + + ItemStack copyStack = checkStack.copy(); + + if (steadfastWill >= steadfastWillDrain) + { + WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.STEADFAST, steadfastWillDrain, true); + steadfastWill -= steadfastWillDrain; + } else + { + continue; + } if (tile != null) - Utils.insertStackIntoTile(copyStack, tile, EnumFacing.DOWN); + copyStack = Utils.insertStackIntoTile(copyStack, tile, EnumFacing.DOWN); else Utils.spawnStackAtBlock(world, pos, EnumFacing.UP, copyStack); - if (copyStack.stackSize > 0) + if (copyStack != null && copyStack.stackSize > 0) { Utils.spawnStackAtBlock(world, pos, EnumFacing.UP, copyStack); } diff --git a/src/main/resources/assets/bloodmagic/lang/en_US.lang b/src/main/resources/assets/bloodmagic/lang/en_US.lang index 488c4ee3..9987ceba 100644 --- a/src/main/resources/assets/bloodmagic/lang/en_US.lang +++ b/src/main/resources/assets/bloodmagic/lang/en_US.lang @@ -486,7 +486,6 @@ ritual.BloodMagic.armourEvolveRitual.info=Undocumented. ritual.BloodMagic.animalGrowthRitual.info=Increases the maturity rate of baby animals within its range. ritual.BloodMagic.forsakenSoulRitual.info=Damages mobs within its damage range and when the mob dies a demon crystal within its crystal range will be grown. ritual.BloodMagic.crystalHarvestRitual.info=Breaks Demon Will crystal clusters within its range, dropping the results on top of the crystals. - ritual.BloodMagic.placerRitual.info=Grabs blocks that are inside of the connected inventory and places them into the world. ritual.BloodMagic.fellingRitual.info=A standard tree-cutting machine, this ritual will cut down all trees and leaves within its area and collect the drops. ritual.BloodMagic.pumpRitual.info=Looks around the world and grabs fluids from the defined area. Will only remove and put the fluid into the connected tank if the tank has at least a bucket's worth of the same fluid.