net.minecraft.network.play.client.C08PacketPlayerBlockPlacement Java Examples

The following examples show how to use net.minecraft.network.play.client.C08PacketPlayerBlockPlacement. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AutoArmor.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Shift+Left clicks the specified item
 *
 * @param item        Slot of the item to click
 * @param isArmorSlot
 * @return True if it is unable to move the item
 */
private boolean move(int item, boolean isArmorSlot) {
    if (!isArmorSlot && item < 9 && hotbarValue.get() && !(mc.currentScreen instanceof GuiInventory)) {
        mc.getNetHandler().addToSendQueue(new C09PacketHeldItemChange(item));
        mc.getNetHandler().addToSendQueue(new C08PacketPlayerBlockPlacement(mc.thePlayer.inventoryContainer.getSlot(item).getStack()));
        mc.getNetHandler().addToSendQueue(new C09PacketHeldItemChange(mc.thePlayer.inventory.currentItem));

        delay = TimeUtils.randomDelay(minDelayValue.get(), maxDelayValue.get());

        return true;
    } else if (!(noMoveValue.get() && MovementUtils.isMoving()) && (!invOpenValue.get() || mc.currentScreen instanceof GuiInventory) && item != -1) {
        final boolean openInventory = simulateInventory.get() && !(mc.currentScreen instanceof GuiInventory);

        if (openInventory)
            mc.getNetHandler().addToSendQueue(new C16PacketClientStatus(C16PacketClientStatus.EnumState.OPEN_INVENTORY_ACHIEVEMENT));

        mc.playerController.windowClick(mc.thePlayer.inventoryContainer.windowId, isArmorSlot ? item : (item < 9 ? item + 36 : item), 0, 1, mc.thePlayer);

        delay = TimeUtils.randomDelay(minDelayValue.get(), maxDelayValue.get());

        if (openInventory)
            mc.getNetHandler().addToSendQueue(new C0DPacketCloseWindow());

        return true;
    }

    return false;
}
 
Example #2
Source File: InventoryUtils.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
@EventTarget
public void onPacket(final PacketEvent event) {
    final Packet packet = event.getPacket();

    if (packet instanceof C08PacketPlayerBlockPlacement)
        CLICK_TIMER.reset();
}
 
Example #3
Source File: WaterFall.java    From ehacks-pro with GNU General Public License v3.0 4 votes vote down vote up
private void useItem() {
    ItemStack item = Wrapper.INSTANCE.player().inventory.getCurrentItem();
    Wrapper.INSTANCE.player().sendQueue.addToSendQueue(new C03PacketPlayer.C05PacketPlayerLook(90.0f, 90.0f, false));
    Wrapper.INSTANCE.mc().playerController.sendUseItem(Wrapper.INSTANCE.player(), Wrapper.INSTANCE.world(), item);
    Wrapper.INSTANCE.player().sendQueue.addToSendQueue(new C08PacketPlayerBlockPlacement((int) Wrapper.INSTANCE.player().posX, Wrapper.INSTANCE.world().getHeightValue((int) Wrapper.INSTANCE.player().posX, (int) Wrapper.INSTANCE.player().posZ), (int) Wrapper.INSTANCE.player().posZ, -1, item, 0.0f, 0.0f, 0.0f));
}
 
Example #4
Source File: FMPPlacementListener.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
public static boolean place(EntityPlayer player, World world){
    MovingObjectPosition hit = RayTracer.reTrace(world, player);
    if(hit == null) return false;

    BlockCoord pos = new BlockCoord(hit.blockX, hit.blockY, hit.blockZ);
    ItemStack held = player.getHeldItem();
    PartPressureTube part = null;
    if(held == null) return false;

    Block heldBlock = Block.getBlockFromItem(held.getItem());
    if(heldBlock == Blockss.pressureTube) {
        part = new PartPressureTube();
    } else if(heldBlock == Blockss.advancedPressureTube) {
        part = new PartAdvancedPressureTube();
    }

    if(part == null) return false;

    if(world.isRemote && !player.isSneaking())//attempt to use block activated like normal and tell the server the right stuff
    {
        Vector3 f = new Vector3(hit.hitVec).add(-hit.blockX, -hit.blockY, -hit.blockZ);
        Block block = world.getBlock(hit.blockX, hit.blockY, hit.blockZ);
        if(!ignoreActivate(block) && block.onBlockActivated(world, hit.blockX, hit.blockY, hit.blockZ, player, hit.sideHit, (float)f.x, (float)f.y, (float)f.z)) {
            player.swingItem();
            PacketCustom.sendToServer(new C08PacketPlayerBlockPlacement(hit.blockX, hit.blockY, hit.blockZ, hit.sideHit, player.inventory.getCurrentItem(), (float)f.x, (float)f.y, (float)f.z));
            return true;
        }
    }

    TileMultipart tile = TileMultipart.getOrConvertTile(world, pos);
    if(tile == null || !tile.canAddPart(part)) {
        pos = pos.offset(hit.sideHit);
        tile = TileMultipart.getOrConvertTile(world, pos);
        if(tile == null || !tile.canAddPart(part)) return false;
    }

    if(!world.isRemote) {
        TileMultipart.addPart(world, pos, part);
        world.playSoundEffect(pos.x + 0.5, pos.y + 0.5, pos.z + 0.5, Blockss.pressureTube.stepSound.func_150496_b(), (Blockss.pressureTube.stepSound.getVolume() + 1.0F) / 2.0F, Blockss.pressureTube.stepSound.getPitch() * 0.8F);
        if(!player.capabilities.isCreativeMode) {
            held.stackSize--;
            if(held.stackSize == 0) {
                player.inventory.mainInventory[player.inventory.currentItem] = null;
                MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(player, held));
            }
        }
    } else {
        player.swingItem();
        NetworkHandler.sendToServer(new PacketFMPPlacePart());
    }
    return true;
}
 
Example #5
Source File: FakeNetServerHandler.java    From Gadomancy with GNU Lesser General Public License v3.0 3 votes vote down vote up
@Override
public void processPlayerBlockPlacement(C08PacketPlayerBlockPlacement p_147346_1_) {
}