Java Code Examples for io.netty.buffer.ByteBuf#writeDouble()

The following examples show how to use io.netty.buffer.ByteBuf#writeDouble() . These examples are extracted from open source projects. 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 Project: pycode-minecraft   File: InvokeWandMessage.java    License: MIT License 6 votes vote down vote up
@Override
public void toBytes(ByteBuf buf) {
    buf.writeDouble(this.traceResult.hitVec.xCoord);
    buf.writeDouble(this.traceResult.hitVec.yCoord);
    buf.writeDouble(this.traceResult.hitVec.zCoord);
    buf.writeShort(this.traceResult.typeOfHit.ordinal());
    switch (this.traceResult.typeOfHit) {
        case ENTITY:
            buf.writeInt(this.traceResult.entityHit.getEntityId());
            break;
        case BLOCK:
            BlockPos blockPos = this.traceResult.getBlockPos();
            buf.writeInt(blockPos.getX());
            buf.writeInt(blockPos.getY());
            buf.writeInt(blockPos.getZ());
            buf.writeShort(this.traceResult.sideHit.ordinal());
    }
}
 
Example 2
Source Project: ftdc   File: ReqOrderAction.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public ByteBuf write(ByteBuf buffer) {
	buffer.writeBytes(brokerID);
	buffer.writeBytes(investorID);
	buffer.writeInt(orderActionRef);
	buffer.writeBytes(orderRef);
	buffer.writeInt(requestID);
	buffer.writeInt(frontID);
	buffer.writeInt(sessionID);
	buffer.writeBytes(exchangeID);
	buffer.writeBytes(orderSysID);
	buffer.writeBytes(actionFlag);
	buffer.writeDouble(limitPrice);
	buffer.writeInt(volumeChange);
	buffer.writeBytes(userID);
	buffer.writeBytes(instrumentID);
	buffer.writeBytes(investUnitID);
	buffer.writeBytes(iPAddress);
	buffer.writeBytes(macAddress);

	return buffer;
}
 
Example 3
public static void writeField(ByteBuf buf, Object value, int type){

        switch(type){
            case 0:
                buf.writeInt((Integer)value);
                break;
            case 1:
                buf.writeFloat((Float)value);
                break;
            case 2:
                buf.writeDouble((Double)value);
                break;
            case 3:
                buf.writeBoolean((Boolean)value);
                break;
            case 4:
                ByteBufUtils.writeUTF8String(buf, (String)value);
                break;
            case 5:
                buf.writeByte((Byte)value);
                break;
            case 6:
                ByteBufUtils.writeItemStack(buf, (ItemStack)value);
                break;
            case 7:
                buf.writeBoolean(value != null);
                if(value != null) {
                    FluidStack stack = (FluidStack)value;
                    ByteBufUtils.writeUTF8String(buf, stack.getFluid().getName());
                    buf.writeInt(stack.amount);
                    ByteBufUtils.writeTag(buf, stack.tag);
                }
                break;
        }
    }
 
Example 4
Source Project: joyqueue   File: JoyQueueMapTools.java    License: Apache License 2.0 5 votes vote down vote up
public static void write(final Object object, final ByteBuf out) {
    if (object instanceof Byte) {
        out.writeByte(BYTE_TYPE);
        out.writeByte(((Byte) object).byteValue());
    } else if (object instanceof Short) {
        out.writeByte(SHORT_TYPE);
        out.writeShort(((Short) object).shortValue());
    } else if (object instanceof Integer) {
        out.writeByte(INT_TYPE);
        out.writeInt(((Integer) object).intValue());
    } else if (object instanceof Long) {
        out.writeByte(LONG_TYPE);
        out.writeLong(((Long) object).longValue());
    } else if (object instanceof Double) {
        out.writeByte(DOUBLE_TYPE);
        out.writeDouble((Double) object);
    } else if (object instanceof String) {
        String str = (String) object;
        byte[] bytes = str.getBytes(UTF8);
        int size = bytes.length;
        if (size <= Byte.MAX_VALUE) {
            out.writeByte(STRING_BYTE_TYPE);
            out.writeByte((byte) size);
        } else if (size <= Short.MAX_VALUE) {
            out.writeByte(STRING_SHORT_TYPE);
            out.writeShort((short) size);
        } else if (size <= Integer.MAX_VALUE) {
            out.writeByte(STRING_INT_TYPE);
            out.writeInt(size);
        }
        out.writeBytes(bytes);
    } else {
        throw new RuntimeException("type is illegal:" + object);
    }
}
 
Example 5
Source Project: ftdc   File: ReqInputOrder.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public ByteBuf write(ByteBuf buffer) {
	buffer.writeBytes(brokerID);
	buffer.writeBytes(investorID);
	buffer.writeBytes(instrumentID);
	buffer.writeBytes(orderRef);
	buffer.writeBytes(userID);
	buffer.writeBytes(orderPriceType);
	buffer.writeBytes(direction);
	buffer.writeBytes(combOffsetFlag);
	buffer.writeBytes(combHedgeFlag);
	buffer.writeDouble(limitPrice);
	buffer.writeInt(volumeTotalOriginal);
	buffer.writeBytes(timeCondition);
	buffer.writeBytes(gTDDate);
	buffer.writeBytes(volumeCondition);
	buffer.writeInt(minVolume);
	buffer.writeBytes(contingentCondition);
	buffer.writeDouble(stopPrice);
	buffer.writeBytes(forceCloseReason);
	buffer.writeInt(isAutoSuspend);
	buffer.writeBytes(businessUnit);
	buffer.writeInt(requestID);
	buffer.writeInt(userForceClose);
	buffer.writeInt(isSwapOrder);
	buffer.writeBytes(exchangeID);
	buffer.writeBytes(investUnitID);
	buffer.writeBytes(accountID);
	buffer.writeInt(currencyID);
	buffer.writeBytes(clientID);
	buffer.writeBytes(iPAddress);
	buffer.writeBytes(macAddress);

	return buffer;
}
 
Example 6
@Override
public void toBytes(ByteBuf buf) {
	buf.writeInt(dimID);
	buf.writeInt(standID);
	buf.writeInt(playerID);
	buf.writeDouble(hitPos.xCoord);
	buf.writeDouble(hitPos.yCoord);
	buf.writeDouble(hitPos.zCoord);
}
 
Example 7
@Override
public void toBytes(ByteBuf buf) {

    buf.writeDouble(x);
    buf.writeDouble(y);
    buf.writeDouble(z);
}
 
Example 8
@Override
public ByteBuf encode(ByteBuf byteBuf, OutPlayerPositionAndLookPacket packet) {

    byteBuf.writeDouble(packet.getPosition().getX());
    byteBuf.writeDouble(packet.getPosition().getY());
    byteBuf.writeDouble(packet.getPosition().getZ());
    byteBuf.writeFloat(packet.getPosition().getRotation().getYaw());
    byteBuf.writeFloat(packet.getPosition().getRotation().getPitch());
    byteBuf.writeByte(packet.getFlags());
    ByteBufUtils.writeVarInt(byteBuf, packet.getTeleportID());

    return byteBuf;
}
 
Example 9
Source Project: Et-Futurum   File: EntityTippedArrow.java    License: The Unlicense 5 votes vote down vote up
@Override
public void writeSpawnData(ByteBuf buffer) {
	buffer.writeFloat(rotationYaw);

	int id = shootingEntity == null ? getEntityId() : shootingEntity.getEntityId();
	buffer.writeInt(id);

	buffer.writeDouble(motionX);
	buffer.writeDouble(motionY);
	buffer.writeDouble(motionZ);

	buffer.writeInt(effect.getPotionID());
	buffer.writeInt(effect.getDuration());
	buffer.writeInt(effect.getAmplifier());
}
 
Example 10
@Override
public void toBytes(ByteBuf buf) {
    buf.writeInt(dimId);
    buf.writeDouble(pedestalX);
    buf.writeDouble(pedestalY);
    buf.writeDouble(pedestalZ);
    buf.writeDouble(originX);
    buf.writeDouble(originY);
    buf.writeDouble(originZ);
    buf.writeInt(tickCap);
    buf.writeInt(colorAsInt);
}
 
Example 11
@Override
public void onMouse(MouseEvent event) {
    MovingObjectPosition mop = Wrapper.INSTANCE.mc().objectMouseOver;
    if (mop.sideHit == -1) {
        return;
    }
    boolean nowState = Mouse.isButtonDown(1);
    if (!prevState && nowState) {
        prevState = nowState;
        TileEntity entity = Wrapper.INSTANCE.world().getTileEntity(mop.blockX, mop.blockY, mop.blockZ);
        try {
            if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && entity != null && !Class.forName("eu.thesociety.DragonbornSR.DragonsRadioMod.Block.TileEntity.TileEntityRadio").isInstance(entity)) {
                ByteBuf buf = Unpooled.buffer(0);
                buf.writeByte(0);
                buf.writeInt(0);
                buf.writeDouble(mop.blockX);
                buf.writeDouble(mop.blockY);
                buf.writeDouble(mop.blockZ);
                buf.writeInt(Wrapper.INSTANCE.player().dimension);
                buf.writeInt(0);
                buf.writeBytes(new byte[0]);
                buf.writeBoolean(false);
                buf.writeFloat(0);
                buf.writeDouble(0);
                buf.writeDouble(0);
                buf.writeDouble(0);
                C17PacketCustomPayload packet = new C17PacketCustomPayload("DragonsRadioMod", buf);
                Wrapper.INSTANCE.player().sendQueue.addToSendQueue(packet);
                InteropUtils.log("Crash sent", this);
                if (event.isCancelable()) {
                    event.setCanceled(true);
                }
            }
        } catch (Exception ex) {
            InteropUtils.log("Error happened", this);
        }
    }
    prevState = nowState;
}
 
Example 12
Source Project: crate   File: PointType.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public int writeAsBinary(ByteBuf buffer, @Nonnull Point point) {
    buffer.writeInt(TYPE_LEN);
    buffer.writeDouble(point.getX());
    buffer.writeDouble(point.getY());
    return INT32_BYTE_SIZE + TYPE_LEN;
}
 
Example 13
@Override
public void toBytes(ByteBuf buffer){
    super.toBytes(buffer);
    ByteBufUtils.writeUTF8String(buffer, particleName);
    buffer.writeDouble(dx);
    buffer.writeDouble(dy);
    buffer.writeDouble(dz);
}
 
Example 14
Source Project: AdvancedRocketry   File: PacketStationUpdate.java    License: MIT License 4 votes vote down vote up
@Override
public void write(ByteBuf out) {
	out.writeInt(stationNumber);
	out.writeInt(type.ordinal());

	switch(type) {
	case DEST_ORBIT_UPDATE:
		out.writeInt(spaceObject.getDestOrbitingBody());
		break;
	case ORBIT_UPDATE:
		out.writeInt(spaceObject.getOrbitingPlanetId());
		break;
	case FUEL_UPDATE:
		if(spaceObject instanceof SpaceObject)
			out.writeInt(((SpaceObject)spaceObject).getFuelAmount());
		break;
	case ROTANGLE_UPDATE:
		out.writeDouble(spaceObject.getRotation(EnumFacing.EAST));
		out.writeDouble(spaceObject.getRotation(EnumFacing.UP));
		out.writeDouble(spaceObject.getRotation(EnumFacing.NORTH));
		out.writeDouble(spaceObject.getDeltaRotation(EnumFacing.EAST));
		out.writeDouble(spaceObject.getDeltaRotation(EnumFacing.UP));
		out.writeDouble(spaceObject.getDeltaRotation(EnumFacing.NORTH));
		break;
	case ALTITUDE_UPDATE:
		out.writeFloat(spaceObject.getOrbitalDistance());
		break;
	case DIM_PROPERTY_UPDATE:
		NBTTagCompound nbt = new NBTTagCompound();
		try {
			spaceObject.getProperties().writeToNBT(nbt);
			PacketBuffer packetBuffer = new PacketBuffer(out);
			packetBuffer.writeCompoundTag(nbt);
		} catch(NullPointerException e) {
			out.writeBoolean(true);
			Logger.getLogger("advancedRocketry").warning("Dimension " + stationNumber + " has thrown an exception trying to write NBT, deleting!");
			DimensionManager.getInstance().deleteDimension(stationNumber);
		}
	default:
	}
}
 
Example 15
@Override
public void encode(FetchHealthResponse payload, ByteBuf buffer) throws Exception {
    buffer.writeDouble(payload.getPoint());
}
 
Example 16
Source Project: ftdc   File: ReqFromBankToFuture.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public ByteBuf write(ByteBuf buffer) {
	buffer.writeBytes(tradeCode);
	buffer.writeBytes(bankID);
	buffer.writeBytes(bankBranchID);
	buffer.writeBytes(brokerID);
	buffer.writeBytes(brokerBranchID);
	buffer.writeBytes(tradeDate);
	buffer.writeBytes(tradeTime);
	buffer.writeBytes(bankSerial);
	buffer.writeBytes(tradingDay);
	buffer.writeInt(plateSerial);
	buffer.writeBytes(lastFragment);
	buffer.writeInt(sessionID);
	buffer.writeBytes(customerName);
	buffer.writeBytes(idCardType);
	buffer.writeBytes(identifiedCardNo);
	buffer.writeBytes(custType);
	buffer.writeBytes(bankAccount);
	buffer.writeBytes(bankPassWord);
	buffer.writeBytes(accountID);
	buffer.writeBytes(password);
	buffer.writeInt(installID);
	buffer.writeInt(futureSerial);
	buffer.writeBytes(userID);
	buffer.writeBytes(verifyCertNoFlag);
	buffer.writeInt(currencyID);
	buffer.writeDouble(tradeAmount);
	buffer.writeDouble(futureFetchAmount);
	buffer.writeBytes(feePayFlag);
	buffer.writeDouble(custFee);
	buffer.writeDouble(brokerFee);
	buffer.writeBytes(message);
	buffer.writeBytes(digest);
	buffer.writeBytes(bankAccType);
	buffer.writeBytes(deviceID);
	buffer.writeBytes(bankSecuAccType);
	buffer.writeBytes(brokerIDByBank);
	buffer.writeBytes(bankSecuAcc);
	buffer.writeBytes(bankPwdFlag);
	buffer.writeBytes(secuPwdFlag);
	buffer.writeBytes(operNo);
	buffer.writeInt(requestID);
	buffer.writeInt(tID);
	buffer.writeBytes(transferStatus);
	buffer.writeBytes(longCustomerName);

	return buffer;
}
 
Example 17
@Override
public void toBytes(ByteBuf buf){
    buf.writeDouble(x);
    buf.writeDouble(y);
    buf.writeDouble(z);
}
 
Example 18
Source Project: ViaVersion   File: DoubleType.java    License: MIT License 4 votes vote down vote up
@Override
public void write(ByteBuf buffer, Double object) {
    buffer.writeDouble(object);
}
 
Example 19
Source Project: vertx-sql-client   File: DataTypeCodec.java    License: Apache License 2.0 4 votes vote down vote up
private static void binaryEncodeFLOAT8(Number value, ByteBuf buff) {
  buff.writeDouble(value.doubleValue());
}
 
Example 20
Source Project: ballerina-message-broker   File: Double.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void write(ByteBuf buf) {
    buf.writeDouble(value);
}