diff --git a/src/main/java/jackyy/exchangers/handler/ExchangerHandler.java b/src/main/java/jackyy/exchangers/handler/ExchangerHandler.java index a3be703..d57e94a 100644 --- a/src/main/java/jackyy/exchangers/handler/ExchangerHandler.java +++ b/src/main/java/jackyy/exchangers/handler/ExchangerHandler.java @@ -89,6 +89,7 @@ public void addInformation(ItemStack stack, EntityPlayer player, List to Block block = Block.getBlockFromName(id); int meta = compound.getInteger("meta"); tooltip.add(StringHelper.localize("tooltip.selected_block") + " " + getBlockName(block, meta)); + /* DEBUG */ tooltip.add("Metadata: " + meta); tooltip.add(StringHelper.localize("tooltip.current_range") + " " + modeSwitchList[compound.getInteger("mode")]); tooltip.add(StringHelper.localize("tooltip.max_range") + " " + modeSwitchList[getMaxRange()]); } @@ -118,13 +119,21 @@ public void switchMode(EntityPlayer player, ItemStack stack) { setDefaultTagCompound(stack); int modeSwitch = stack.getTagCompound().getInteger("mode"); - modeSwitch++; + + if (player.isSneaking()) { + modeSwitch--; + } else { + modeSwitch++; + } ItemStack heldItem = player.getHeldItemMainhand(); if (heldItem != null) { - if (modeSwitch > getMaxRange()) + if (modeSwitch > getMaxRange()) { modeSwitch = MODE_1X1; + } else if (modeSwitch < MODE_1X1) { + modeSwitch = getMaxRange(); + } } stack.getTagCompound().setInteger("mode", modeSwitch); @@ -153,7 +162,6 @@ private boolean isWhitelisted(World world, BlockPos pos) { private boolean isSpecial(Block block) { return block instanceof BlockLog - || block instanceof BlockLeaves || block instanceof BlockRedstoneOre || block instanceof BlockTrapDoor || block instanceof BlockDoor @@ -218,6 +226,9 @@ private void placeBlock(ItemStack stack, EntityPlayer player, World world, Block world.playSound(null, coordinate.getX(), coordinate.getY(), coordinate.getZ(), SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.BLOCKS, 0.1F, 1F); } else { + world.restoringBlockSnapshots = true; + event.getBlockSnapshot().restore(true); + world.restoringBlockSnapshots = false; notEnough = true; } } else { @@ -227,10 +238,10 @@ private void placeBlock(ItemStack stack, EntityPlayer player, World world, Block ChatHelper.msgPlayer(player, "error.event_cancelled"); } } - world.captureBlockSnapshots = true; if (notEnough) { ChatHelper.msgPlayer(player, "error.out_of_block"); } + world.captureBlockSnapshots = true; } @SuppressWarnings("deprecation")