Ritual portal delay / Bound Pickaxe fix/improvement (#1387)

* Teleportation now works similar to the Nether Portal:

if teleportation is attempted before the cooldown (10 ticks) is over, the cooldown gets reset.
This way teleportation loops are prevented.

You can now:
- Stand on a loop of permanently activated (well, constantly refreshing through a high-speed redstone clock) Teleposers, only getting teleposed once per stepping on it
- AFK in the Gate of the Fold without getting teleported constantly
- and other things, I guess.

* Bound Pickaxe AoE ability now destroys blocks properly.

closes #1001

* Streamlined bound tool harvest code.

Cleanup, duplicate code for bound tools moved as method to ItemBoundTool.sharedHarvest()

Tested aoe harvest with Stone, Dirt/Grass and Oak trees. Same result as before.

* silkTouch and fortuneLvl are now passed instead of recalculated on every block
This commit is contained in:
AEon - Tobias 2018-08-26 21:50:02 +02:00 committed by Nick Ignoffo
parent 72eb314da8
commit 753958ac9c
5 changed files with 40 additions and 64 deletions

View file

@ -1,20 +1,19 @@
package WayofTime.bloodmagic.item;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
import WayofTime.bloodmagic.core.data.Binding;
import WayofTime.bloodmagic.core.data.SoulTicket;
import WayofTime.bloodmagic.util.ItemStackWrapper;
import WayofTime.bloodmagic.event.BoundToolEvent;
import WayofTime.bloodmagic.iface.IActivatable;
import WayofTime.bloodmagic.iface.IBindable;
import WayofTime.bloodmagic.util.helper.NetworkHelper;
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
import WayofTime.bloodmagic.util.BlockStack;
import WayofTime.bloodmagic.util.ItemStackWrapper;
import WayofTime.bloodmagic.util.Utils;
import WayofTime.bloodmagic.util.helper.NetworkHelper;
import WayofTime.bloodmagic.util.helper.TextHelper;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Multimap;
import com.google.common.collect.Multiset;
import com.google.common.collect.*;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.util.ITooltipFlag;
@ -251,4 +250,22 @@ public class ItemBoundTool extends ItemTool implements IBindable, IActivatable {
world.spawnEntity(new EntityItem(world, posToDrop.getX(), posToDrop.getY(), posToDrop.getZ(), stack.toStack(count)));
}
}
protected void sharedHarvest(ItemStack stack, World world, EntityPlayer player, BlockPos blockPos, BlockStack blockStack, HashMultiset drops, boolean silkTouch, int fortuneLvl){
if (blockStack.getBlock() != null && blockStack.getState().getBlockHardness(world, blockPos) != -1.0F) {
float strengthVsBlock = getDestroySpeed(stack, blockStack.getState());
if (strengthVsBlock > 1.1F && world.canMineBlockBody(player, blockPos)) {
if (silkTouch && blockStack.getBlock().canSilkHarvest(world, blockPos, world.getBlockState(blockPos), player))
drops.add(new ItemStackWrapper(blockStack));
else {
List<ItemStack> itemDrops = blockStack.getBlock().getDrops(world, blockPos, world.getBlockState(blockPos), fortuneLvl);
for (ItemStack stacks : itemDrops)
drops.add(ItemStackWrapper.getHolder(stacks));
}
blockStack.getBlock().removedByPlayer(world.getBlockState(blockPos), world, blockPos,player, false);
}
}
}
}