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

The following examples show how to use io.netty.buffer.ByteBuf#writeDouble() . 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: InvokeWandMessage.java    From pycode-minecraft with 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 File: ReqOrderAction.java    From ftdc with 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
Source File: PacketUpdateGui.java    From Signals with GNU General Public License v3.0 5 votes vote down vote up
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 File: PacketSpawnParticle.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void toBytes(ByteBuf buffer){
    super.toBytes(buffer);
    ByteBufUtils.writeUTF8String(buffer, particleName);
    buffer.writeDouble(dx);
    buffer.writeDouble(dy);
    buffer.writeDouble(dz);
}
 
Example 5
Source File: PointType.java    From crate with 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 6
Source File: MusicalCrash.java    From ehacks-pro with GNU General Public License v3.0 5 votes vote down vote up
@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 7
Source File: PacketTCWispyLine.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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 8
Source File: EntityTippedArrow.java    From Et-Futurum with 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 9
Source File: OutPlayerPositionAndLookCodec.java    From Cleanstone with MIT License 5 votes vote down vote up
@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 10
Source File: LocationDoublePacket.java    From Signals with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void toBytes(ByteBuf buf) {

    buf.writeDouble(x);
    buf.writeDouble(y);
    buf.writeDouble(z);
}
 
Example 11
Source File: ArmourStandInteractMessage.java    From Et-Futurum with The Unlicense 5 votes vote down vote up
@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 12
Source File: ReqInputOrder.java    From ftdc with 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 13
Source File: JoyQueueMapTools.java    From joyqueue with 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 14
Source File: DoubleType.java    From ViaVersion with MIT License 4 votes vote down vote up
@Override
public void write(ByteBuf buffer, Double object) {
    buffer.writeDouble(object);
}
 
Example 15
Source File: LocationDoublePacket.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void toBytes(ByteBuf buf){
    buf.writeDouble(x);
    buf.writeDouble(y);
    buf.writeDouble(z);
}
 
Example 16
Source File: ReqFromBankToFuture.java    From ftdc with 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
Source File: FetchHealthResponseCodec.java    From joyqueue with Apache License 2.0 4 votes vote down vote up
@Override
public void encode(FetchHealthResponse payload, ByteBuf buffer) throws Exception {
    buffer.writeDouble(payload.getPoint());
}
 
Example 18
Source File: PacketStationUpdate.java    From AdvancedRocketry with 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 19
Source File: DataTypeCodec.java    From vertx-sql-client with 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 File: Double.java    From ballerina-message-broker with Apache License 2.0 4 votes vote down vote up
@Override
public void write(ByteBuf buf) {
    buf.writeDouble(value);
}