Java Code Examples for codechicken.lib.packet.PacketCustom#readBoolean()

The following examples show how to use codechicken.lib.packet.PacketCustom#readBoolean() . 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: WRAddonSPH.java    From WirelessRedstone with MIT License 6 votes vote down vote up
private void handlePacket(WorldServer world, EntityPlayerMP player, PacketCustom packet) {
    switch (packet.getType()) {
        case 50:
            if (packet.readBoolean())
                RedstoneEtherAddons.server().addSniffer(player);
            else
                RedstoneEtherAddons.server().remSniffer(player);
            break;
        case 51:
            if (packet.readBoolean())
                RedstoneEtherAddons.server().activateRemote(world, player);
            else
                RedstoneEtherAddons.server().deactivateRemote(world, player);
            break;
        case 52:
            RedstoneEtherAddons.server().setTriangRequired(player, packet.readUShort(), packet.readBoolean());
            break;
        case 58:
            RedstoneEtherAddons.server().clearMapNodes(player);
            break;
    }
}
 
Example 2
Source File: ContainerPotionCreator.java    From NotEnoughItems with MIT License 6 votes vote down vote up
@SuppressWarnings ("unchecked")
@Override
public void handleInputPacket(PacketCustom packet) {
    ItemStack potion = potionInv.getStackInSlot(0);
    if (potion == null) {
        return;
    }

    boolean add = packet.readBoolean();
    Potion effect = Potion.getPotionById(packet.readUByte());

    NBTTagList effects = potion.getTagCompound().getTagList("CustomPotionEffects", 10);
    NBTTagList newEffects = new NBTTagList();
    for (int i = 0; i < effects.tagCount(); i++) {
        NBTTagCompound tag = effects.getCompoundTagAt(i);
        PotionEffect e = PotionEffect.readCustomPotionEffectFromNBT(tag);
        if (e.getPotion() != effect) {
            newEffects.appendTag(tag);
        }
    }
    if (add) {
        newEffects.appendTag(new PotionEffect(effect, packet.readInt(), packet.readUByte()).writeCustomPotionEffectToNBT(new NBTTagCompound()));
    }
    potion.getTagCompound().setTag("CustomPotionEffects", newEffects);
}
 
Example 3
Source File: ContainerPotionCreator.java    From NotEnoughItems with MIT License 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void handleInputPacket(PacketCustom packet) {
    ItemStack potion = potionInv.getStackInSlot(0);
    if (potion == null)
        return;

    boolean add = packet.readBoolean();
    int effectID = packet.readUByte();

    NBTTagList effects = potion.getTagCompound().getTagList("CustomPotionEffects", 10);
    NBTTagList newEffects = new NBTTagList();
    for(int i = 0; i < effects.tagCount(); i++) {
        NBTTagCompound tag = effects.getCompoundTagAt(i);
        PotionEffect e = PotionEffect.readCustomPotionEffectFromNBT(tag);
        if(e.getPotionID() != effectID)
            newEffects.appendTag(tag);
    }
    if(add)
        newEffects.appendTag(new PotionEffect(effectID, packet.readInt(), packet.readUByte()).writeCustomPotionEffectToNBT(new NBTTagCompound()));
    potion.getTagCompound().setTag("CustomPotionEffects", newEffects);
}
 
Example 4
Source File: PlayerChunkViewer.java    From ChickenChunks with MIT License 6 votes vote down vote up
public TicketInfo(PacketCustom packet, WorldClient world)
{
    ID = packet.readInt();
    modId = packet.readString();
    if(packet.readBoolean())
        player = packet.readString();
    type = net.minecraftforge.common.ForgeChunkManager.Type.values()[packet.readUByte()];
    if(type == net.minecraftforge.common.ForgeChunkManager.Type.ENTITY)
        entity = world.getEntityByID(packet.readInt());
    int chunks = packet.readUShort();
    chunkSet = new HashSet<ChunkCoordIntPair>(chunks);
    for(int i = 0; i < chunks; i++)
    {
        chunkSet.add(new ChunkCoordIntPair(packet.readInt(), packet.readInt()));
    }
}
 
Example 5
Source File: WRAddonCPH.java    From WirelessRedstone with MIT License 5 votes vote down vote up
private void handlePacket(WorldClient world, EntityPlayer player, PacketCustom packet) {
    switch (packet.getType()) {
        case 53:
            processSnifferFreqUpdate(packet);
            break;
        case 54:
            processSnifferEtherCopy(packet);
            break;
        case 55:
            RedstoneEtherAddons.client().setTriangAngle(packet.readUShort(), packet.readFloat());
            break;
        case 56:
            processMapInfo(world, player, packet);
            break;
        case 57:
            processMapUpdate(world, player, packet);
            break;
        case 59:
            if (packet.readBoolean())
                throwREP(packet.readInt(), packet.readInt(), world, player);
            else
                world.removeEntityFromWorld(packet.readInt());
            break;
        case 60:
            processTrackerUpdate(packet, world, player);
            break;
        case 61:
            if (packet.readBoolean())
                throwTracker(world, player, packet.readInt(), packet.readInt(), packet.readUShort());
            else
                world.removeEntityFromWorld(packet.readInt());
            break;
    }
}
 
Example 6
Source File: TileEnderTank.java    From EnderStorage with MIT License 5 votes vote down vote up
public void sync(PacketCustom packet) {
    if (packet.getType() == 5) {
        liquid_state.sync(packet.readFluidStack());
    } else if (packet.getType() == 6) {
        pressure_state.a_pressure = packet.readBoolean();
    }
}
 
Example 7
Source File: TileItemTranslocator.java    From Translocators with MIT License 5 votes vote down vote up
@Override
public void read(PacketCustom packet, boolean described)
{
    super.read(packet, described);
    regulate = packet.readBoolean();
    signal = packet.readBoolean();
    a_powering = packet.readBoolean();
}
 
Example 8
Source File: TileTranslocator.java    From Translocators with MIT License 5 votes vote down vote up
public void read(PacketCustom packet, boolean described)
{
    a_eject = packet.readBoolean();
    redstone = packet.readBoolean();
    fast = packet.readBoolean();
    
    if(!described)
        a_insertpos = b_insertpos = approachInsertPos();
}
 
Example 9
Source File: NEICPH.java    From NotEnoughItems with MIT License 5 votes vote down vote up
private void handleActionDisabled(PacketCustom packet) {
    String name = packet.readString();
    if (packet.readBoolean())
        NEIClientConfig.disabledActions.add(name);
    else
        NEIClientConfig.disabledActions.remove(name);
}
 
Example 10
Source File: NEICPH.java    From NotEnoughItems with MIT License 5 votes vote down vote up
private void handleActionEnabled(PacketCustom packet) {
    String name = packet.readString();
    if (packet.readBoolean())
        NEIClientConfig.enabledActions.add(name);
    else
        NEIClientConfig.enabledActions.remove(name);
}
 
Example 11
Source File: NEICPH.java    From NotEnoughItems with MIT License 5 votes vote down vote up
@Override
public void handlePacket(PacketCustom packet, Minecraft mc, INetHandlerPlayClient netHandler) {
    switch (packet.getType()) {
        case 1:
            handleSMPCheck(packet.readUByte(), packet.readString(), mc.theWorld);
            break;
        case 10:
            handleLoginState(packet);
            break;
        case 11:
            handleActionDisabled(packet);
            break;
        case 12:
            handleActionEnabled(packet);
            break;
        case 13:
            ClientHandler.instance().addSMPMagneticItem(packet.readInt(), mc.theWorld);
            break;
        case 14:
            handleGamemode(mc, packet.readUByte());
            break;
        case 21:
            ClientUtils.openSMPGui(packet.readUByte(), new GuiEnchantmentModifier(mc.thePlayer.inventory, mc.theWorld));
            break;
        case 23:
            if (packet.readBoolean())
                ClientUtils.openSMPGui(packet.readUByte(), new GuiExtendedCreativeInv(new ContainerCreativeInv(mc.thePlayer, new ExtendedCreativeInv(null, Side.CLIENT))));
            else
                mc.displayGuiScreen(new GuiInventory(mc.thePlayer));
            break;
        case 24:
            ClientUtils.openSMPGui(packet.readUByte(), new GuiPotionCreator(mc.thePlayer.inventory));
            break;
    }
}
 
Example 12
Source File: NEISPH.java    From NotEnoughItems with MIT License 5 votes vote down vote up
private void setInventorySlot(EntityPlayerMP player, PacketCustom packet) {
    boolean container = packet.readBoolean();
    int slot = packet.readShort();
    ItemStack item = packet.readItemStack();

    ItemStack old = NEIServerUtils.getSlotContents(player, slot, container);
    boolean deleting = item == null || old != null && NEIServerUtils.areStacksSameType(item, old) && item.stackSize < old.stackSize;
    if (NEIServerConfig.canPlayerPerformAction(player.getCommandSenderName(), deleting ? "delete" : "item"))
        NEIServerUtils.setSlotContents(player, slot, item, container);
}
 
Example 13
Source File: TileSpotLoader.java    From ChickenChunks with MIT License 5 votes vote down vote up
public static void handleDescriptionPacket(PacketCustom packet, World world) {
    TileEntity tile = world.getTileEntity(packet.readInt(), packet.readInt(), packet.readInt());
    if (tile instanceof TileSpotLoader) {
        TileSpotLoader ctile = (TileSpotLoader) tile;
        ctile.active = packet.readBoolean();
        if (packet.readBoolean())
            ctile.owner = packet.readString();
    }
}
 
Example 14
Source File: TileChunkLoader.java    From ChickenChunks with MIT License 5 votes vote down vote up
public static void handleDescriptionPacket(PacketCustom packet, World world)
{
    TileEntity tile = world.getTileEntity(packet.readInt(), packet.readInt(), packet.readInt());
    if(tile instanceof TileChunkLoader)
    {        
        TileChunkLoader ctile = (TileChunkLoader)tile;         
        ctile.setShapeAndRadius(ChunkLoaderShape.values()[packet.readUByte()], packet.readUByte());
        ctile.active = packet.readBoolean();
        if(packet.readBoolean())
            ctile.owner = packet.readString();
    }
}
 
Example 15
Source File: TileEnderTank.java    From EnderStorage with MIT License 5 votes vote down vote up
@Override
public void handleDescriptionPacket(PacketCustom desc) {
    super.handleDescriptionPacket(desc);
    rotation = desc.readUByte();
    liquid_state.s_liquid = desc.readFluidStack();
    pressure_state.a_pressure = desc.readBoolean();
    if (!described) {
        liquid_state.c_liquid = liquid_state.s_liquid;
        pressure_state.b_rotate = pressure_state.a_rotate = pressure_state.approachRotate();
    }
    described = true;
}
 
Example 16
Source File: NEIClientPacketHandler.java    From NotEnoughItems with MIT License 5 votes vote down vote up
/**
 * Handles when an action is disabled.
 * For Example. Noon, Weather.
 *
 * @param packet The packet to handle.
 */
private void handleActionDisableStateChange(PacketCustom packet) {
    String name = packet.readString();
    if (packet.readBoolean()) {
        NEIClientConfig.disabledActions.add(name);
    } else {
        NEIClientConfig.disabledActions.remove(name);
    }
}
 
Example 17
Source File: NEIClientPacketHandler.java    From NotEnoughItems with MIT License 5 votes vote down vote up
@Override
public void handlePacket(PacketCustom packet, Minecraft mc, INetHandlerPlayClient netHandler) {
    switch (packet.getType()) {
        case 1:
            handleServerSideCheck(packet.readUByte(), packet.readString(), mc.world);
            break;
        case 10:
            handleLoginState(packet);
            break;
        case 11:
            handleActionDisableStateChange(packet);
            break;
        case 12:
            handleActionEnabled(packet);
            break;
        case 13:
            MagnetModeHandler.INSTANCE.trackMagnetItem(packet.readInt(), mc.world);
            break;
        case 14:
            handleGameMode(mc, packet.readUByte());
            break;
        case 21:
            ClientUtils.openSMPGui(packet.readUByte(), new GuiEnchantmentModifier(mc.player.inventory, mc.world));
            break;
        case 23:
            if (packet.readBoolean()) {
                ClientUtils.openSMPGui(packet.readUByte(), new GuiExtendedCreativeInv(new ContainerCreativeInv(mc.player, new ExtendedCreativeInv(null, Side.CLIENT))));
            } else {
                mc.displayGuiScreen(new GuiInventory(mc.player));
            }
            break;
        case 24:
            ClientUtils.openSMPGui(packet.readUByte(), new GuiPotionCreator(mc.player.inventory));
            break;
    }
}
 
Example 18
Source File: NEIServerPacketHandler.java    From NotEnoughItems with MIT License 5 votes vote down vote up
private void setInventorySlot(EntityPlayerMP player, PacketCustom packet) {
    boolean container = packet.readBoolean();
    int slot = packet.readShort();
    ItemStack item = packet.readItemStack();

    ItemStack old = NEIServerUtils.getSlotContents(player, slot, container);
    boolean deleting = item.isEmpty() || !old.isEmpty() && NEIServerUtils.areStacksSameType(item, old) && item.getCount() < old.getCount();
    if (NEIServerConfig.canPlayerPerformAction(player.getName(), deleting ? "delete" : "item")) {
        NEIServerUtils.setSlotContents(player, slot, item, container);
    }
}
 
Example 19
Source File: TileEnderTank.java    From EnderStorage with MIT License 4 votes vote down vote up
public void sync(PacketCustom packet) {
    if (packet.getType() == 5)
        liquid_state.sync(packet.readFluidStack());
    else if (packet.getType() == 6)
        pressure_state.a_pressure = packet.readBoolean();
}
 
Example 20
Source File: WRAddonCPH.java    From WirelessRedstone with MIT License 4 votes vote down vote up
private void processTrackerUpdate(PacketCustom packet, WorldClient world, EntityPlayer player) {
    int entityID = packet.readInt();
    int freq = packet.readUShort();
    boolean attached = packet.readBoolean();

    Entity e = world.getEntityByID(entityID);
    if (e != null && e.isDead)
        e = null;

    if (!(e instanceof EntityWirelessTracker)) {
        if (e != null)
            throw new IllegalStateException("EntityID mapped to non tracker");

        e = new EntityWirelessTracker(world, freq);
        e.setEntityId(entityID);
        world.addEntityToWorld(entityID, e);
    }
    EntityWirelessTracker tracker = (EntityWirelessTracker) e;

    if (attached) {
        int attachedEntityID = packet.readInt();

        Entity attachedEntity;
        if (attachedEntityID == player.getEntityId())
            attachedEntity = player;
        else
            attachedEntity = world.getEntityByID(attachedEntityID);

        if (attachedEntity == null) {
            return;
        }

        tracker.attached = true;
        tracker.attachedEntity = attachedEntity;
        tracker.attachedX = packet.readFloat();
        tracker.attachedY = packet.readFloat();
        tracker.attachedZ = packet.readFloat();
        tracker.attachedYaw = packet.readFloat();
    } else {
        tracker.attachedEntity = null;
        tracker.attached = false;

        tracker.posX = packet.readFloat();
        tracker.posY = packet.readFloat();
        tracker.posZ = packet.readFloat();
        tracker.motionX = packet.readFloat();
        tracker.motionY = packet.readFloat();
        tracker.motionZ = packet.readFloat();

        tracker.setPosition(tracker.posX, tracker.posY, tracker.posZ);
        tracker.setVelocity(tracker.motionX, tracker.motionY, tracker.motionZ);

        tracker.attachmentCounter = packet.readUShort();
        tracker.item = packet.readBoolean();
    }
}