Fixed issue #23 dank/null compat only uses one block at a time regardless of how many are placed.
This commit is contained in:
@@ -1,9 +1,11 @@
|
|||||||
package nl.requios.effortlessbuilding.compatibility;
|
package nl.requios.effortlessbuilding.compatibility;
|
||||||
|
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemBlock;
|
import net.minecraft.item.ItemBlock;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.EnumHand;
|
||||||
import net.minecraftforge.fml.common.Loader;
|
import net.minecraftforge.fml.common.Loader;
|
||||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||||
import net.minecraftforge.items.CapabilityItemHandler;
|
import net.minecraftforge.items.CapabilityItemHandler;
|
||||||
@@ -90,7 +92,10 @@ public class CompatHelper {
|
|||||||
|
|
||||||
// Handle IItemHandler slot stacks not being modifiable. We must call IItemHandler#extractItem,
|
// Handle IItemHandler slot stacks not being modifiable. We must call IItemHandler#extractItem,
|
||||||
// because the ItemStack returned by IItemHandler#getStackInSlot isn't modifiable.
|
// because the ItemStack returned by IItemHandler#getStackInSlot isn't modifiable.
|
||||||
public static void shrinkStack(ItemStack origStack, ItemStack curStack) {
|
public static void shrinkStack(ItemStack origStack, ItemStack curStack, EntityPlayer player) {
|
||||||
|
//Hacky way to get the origstack, because given origStack is itemblock stack and never a proxy
|
||||||
|
origStack = player.getHeldItem(EnumHand.MAIN_HAND);
|
||||||
|
|
||||||
if (origStack.getItem() == dankNullItem) {
|
if (origStack.getItem() == dankNullItem) {
|
||||||
int index = itemHandlerSlotForItem(origStack, curStack.getItem());
|
int index = itemHandlerSlotForItem(origStack, curStack.getItem());
|
||||||
origStack.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null).extractItem(index, 1, false);
|
origStack.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null).extractItem(index, 1, false);
|
||||||
|
|||||||
@@ -29,10 +29,10 @@ public class ReachHelper {
|
|||||||
public static int getMaxBlocksPlacedAtOnce(EntityPlayer player) {
|
public static int getMaxBlocksPlacedAtOnce(EntityPlayer player) {
|
||||||
if (player.isCreative()) return 1000000;
|
if (player.isCreative()) return 1000000;
|
||||||
return MathHelper.ceil(Math.pow(getMaxReach(player), 1.6));
|
return MathHelper.ceil(Math.pow(getMaxReach(player), 1.6));
|
||||||
//Level 0: 90
|
//Level 0: 121
|
||||||
//Level 1: 353
|
//Level 1: 523
|
||||||
//Level 2: 1000
|
//Level 2: 1585
|
||||||
//Level 3: 2828
|
//Level 3: 4805
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getMaxBlocksPerAxis(EntityPlayer player) {
|
public static int getMaxBlocksPerAxis(EntityPlayer player) {
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ public class SurvivalHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!player.isCreative() && Block.getBlockFromItem(itemstack.getItem()) == block) {
|
if (!player.isCreative() && Block.getBlockFromItem(itemstack.getItem()) == block) {
|
||||||
CompatHelper.shrinkStack(origstack, itemstack);
|
CompatHelper.shrinkStack(origstack, itemstack, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user