Search in sources :

Example 1 with PacketCoordTrackUpdate

use of pneumaticCraft.common.network.PacketCoordTrackUpdate in project PneumaticCraft by MineMaarten.

the class CoordTrackUpgradeHandler method onPlayerInteract.

@SubscribeEvent
public boolean onPlayerInteract(PlayerInteractEvent event) {
    if (event.action == Action.RIGHT_CLICK_BLOCK && isListeningToCoordTrackerSetting) {
        isListeningToCoordTrackerSetting = false;
        ForgeDirection dir = ForgeDirection.getOrientation(event.face);
        reset();
        ItemStack stack = event.entityPlayer.getCurrentArmor(3);
        if (stack != null) {
            NBTTagCompound tag = NBTUtil.getCompoundTag(stack, "CoordTracker");
            tag.setInteger("dimID", event.entity.worldObj.provider.dimensionId);
            tag.setInteger("x", event.x + dir.offsetX);
            tag.setInteger("y", event.y + dir.offsetY);
            tag.setInteger("z", event.z + dir.offsetZ);
        }
        NetworkHandler.sendToServer(new PacketCoordTrackUpdate(event.entity.worldObj, event.x + dir.offsetX, event.y + dir.offsetY, event.z + dir.offsetZ));
    }
    return false;
}
Also used : ForgeDirection(net.minecraftforge.common.util.ForgeDirection) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) PacketCoordTrackUpdate(pneumaticCraft.common.network.PacketCoordTrackUpdate) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Aggregations

SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)1 ItemStack (net.minecraft.item.ItemStack)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)1 PacketCoordTrackUpdate (pneumaticCraft.common.network.PacketCoordTrackUpdate)1