List of usage examples for io.netty.buffer ByteBuf readFloat
public abstract float readFloat();
From source file:appeng.core.sync.packets.PacketClick.java
License:Open Source License
public PacketClick(final ByteBuf stream) { this.x = stream.readInt(); this.y = stream.readInt(); this.z = stream.readInt(); byte side = stream.readByte(); if (side != -1) { this.side = EnumFacing.values()[side]; } else {//from w w w . j a va 2s . c o m this.side = null; } this.hitX = stream.readFloat(); this.hitY = stream.readFloat(); this.hitZ = stream.readFloat(); this.hand = EnumHand.values()[stream.readByte()]; }
From source file:appeng.core.sync.packets.PacketLightning.java
License:Open Source License
public PacketLightning(final ByteBuf stream) { this.x = stream.readFloat(); this.y = stream.readFloat(); this.z = stream.readFloat(); }
From source file:appeng.core.sync.packets.PacketMatterCannon.java
License:Open Source License
public PacketMatterCannon(final ByteBuf stream) { this.x = stream.readFloat(); this.y = stream.readFloat(); this.z = stream.readFloat(); this.dx = stream.readFloat(); this.dy = stream.readFloat(); this.dz = stream.readFloat(); this.len = stream.readByte(); }
From source file:appeng.core.sync.packets.PacketPartPlacement.java
License:Open Source License
public PacketPartPlacement(final ByteBuf stream) { this.x = stream.readInt(); this.y = stream.readInt(); this.z = stream.readInt(); this.face = stream.readByte(); this.eyeHeight = stream.readFloat(); this.hand = EnumHand.values()[stream.readByte()]; }
From source file:appeng.core.sync.packets.PacketTransitionEffect.java
License:Open Source License
public PacketTransitionEffect(final ByteBuf stream) { this.x = stream.readFloat(); this.y = stream.readFloat(); this.z = stream.readFloat(); this.d = AEPartLocation.fromOrdinal(stream.readByte()); this.mode = stream.readBoolean(); }
From source file:buildcraft.builders.TileQuarry.java
License:Minecraft Mod Public
@Override public void readData(ByteBuf stream) { super.readData(stream); box.readData(stream);// ww w . j a v a 2 s . c o m targetX = stream.readInt(); targetY = stream.readUnsignedShort(); targetZ = stream.readInt(); headPosX = stream.readDouble(); headPosY = stream.readDouble(); headPosZ = stream.readDouble(); speed = stream.readFloat(); headTrajectory = stream.readFloat(); int flags = stream.readUnsignedByte(); stage = Stage.values()[flags & 0x07]; movingHorizontally = (flags & 0x10) != 0; movingVertically = (flags & 0x20) != 0; int newLedState = stream.readUnsignedByte(); if (newLedState != ledState) { ledState = newLedState; worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord); } createUtilsIfNeeded(); if (arm != null) { arm.setHead(headPosX, headPosY, headPosZ); arm.updatePosition(); } }
From source file:buildcraft.core.network.PacketPayloadArrays.java
License:Minecraft Mod Public
@Override public void readData(ByteBuf data) { intPayload = new int[data.readInt()]; floatPayload = new float[data.readInt()]; stringPayload = new String[data.readInt()]; for (int i = 0; i < intPayload.length; i++) { intPayload[i] = data.readInt();/* w ww . j a v a2 s . c o m*/ } for (int i = 0; i < floatPayload.length; i++) { floatPayload[i] = data.readFloat(); } for (int i = 0; i < stringPayload.length; i++) { stringPayload[i] = Utils.readUTF(data); } }
From source file:buildcraft.core.network.RPCHandler.java
License:Minecraft Mod Public
private void internalRpcReceive(Object o, RPCMessageInfo info, ByteBuf data) { try {//from w ww . ja v a 2 s . c o m short methodIndex = data.readShort(); MethodMapping m = methods[methodIndex]; Class[] formals = m.parameters; Object[] actuals = new Object[formals.length]; int expectedParameters = m.hasInfo ? formals.length - 1 : formals.length; SerializationContext context = new SerializationContext(); for (int i = 0; i < expectedParameters; ++i) { if (int.class.equals(formals[i])) { actuals[i] = data.readInt(); } else if (float.class.equals(formals[i])) { actuals[i] = data.readFloat(); } else if (char.class.equals(formals[i])) { actuals[i] = data.readChar(); } else { actuals[i] = m.mappings[i].read(data, actuals[i], context); } } if (m.hasInfo) { actuals[actuals.length - 1] = info; } m.method.invoke(o, actuals); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (InstantiationException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } }
From source file:buildcraft.core.network.serializers.ClassMapping.java
License:Minecraft Mod Public
@SuppressWarnings("rawtypes") Object readClass(Object objI, ByteBuf data, SerializationContext context) throws IllegalArgumentException, IllegalAccessException, InstantiationException, ClassNotFoundException { Object obj = objI;//w w w . j av a 2 s .c o m // The data layout for an object is the following: // [boolean] does the object exist (e.g. non-null) // {false} exit // [int] what is the object real class? // {0} the same as the declared class // {1-x} a different one // [string] if the number is not yet registered, the name of the // class // [bytes] the actual contents int index = data.readByte(); if (index != 0) { ClassMapping delegateMapping; if (context.idToClass.size() < index) { String className = Utils.readUTF(data); Class cls = Class.forName(className); delegateMapping = (ClassMapping) get(cls); context.idToClass.add(get(cls)); } else { delegateMapping = (ClassMapping) context.idToClass.get(index - 1); } return delegateMapping.readClass(obj, data, context); } if (obj == null) { obj = mappedClass.newInstance(); } for (Field f : shortFields) { f.setShort(obj, data.readShort()); } for (Field f : intFields) { f.setInt(obj, data.readInt()); } for (Field f : booleanFields) { f.setBoolean(obj, data.readBoolean()); } for (Field f : enumFields) { f.set(obj, ((Class) f.getGenericType()).getEnumConstants()[data.readByte()]); } for (Field f : floatFields) { f.setFloat(obj, data.readFloat()); } for (Field f : doubleFields) { f.setDouble(obj, data.readDouble()); } for (FieldObject f : objectFields) { f.field.set(obj, f.mapping.read(data, f.field.get(obj), context)); } return obj; }
From source file:buildcraft.core.network.serializers.ClassMapping.java
License:Minecraft Mod Public
private Object readArray(Object objI, ByteBuf data, SerializationContext context) throws IllegalArgumentException, IllegalAccessException, InstantiationException, ClassNotFoundException {/*from w w w .j av a 2 s. co m*/ Object obj = objI; Class<? extends Object> cpt = mappedClass.getComponentType(); int size = data.readInt(); switch (cptType) { case Byte: { byte[] arr; if (obj == null) { arr = new byte[size]; } else { arr = (byte[]) obj; } data.readBytes(arr); obj = arr; break; } case Float: { float[] arr; if (obj == null) { arr = new float[size]; } else { arr = (float[]) obj; } for (int i = 0; i < arr.length; ++i) { arr[i] = data.readFloat(); } obj = arr; break; } case Double: { double[] arr; if (obj == null) { arr = new double[size]; } else { arr = (double[]) obj; } for (int i = 0; i < arr.length; ++i) { arr[i] = data.readDouble(); } obj = arr; break; } case Short: { short[] arr; if (obj == null) { arr = new short[size]; } else { arr = (short[]) obj; } for (int i = 0; i < arr.length; ++i) { arr[i] = data.readShort(); } obj = arr; break; } case Int: { int[] arr; if (obj == null) { arr = new int[size]; } else { arr = (int[]) obj; } for (int i = 0; i < arr.length; ++i) { arr[i] = data.readInt(); } obj = arr; break; } case Boolean: { boolean[] arr; if (obj == null) { arr = new boolean[size]; } else { arr = (boolean[]) obj; } for (int i = 0; i < arr.length; ++i) { arr[i] = data.readBoolean(); } obj = arr; break; } case Object: { Object[] arr; if (obj == null) { arr = (Object[]) Array.newInstance(cpt, size); } else { arr = (Object[]) obj; } for (int i = 0; i < arr.length; ++i) { arr[i] = cptMapping.read(data, arr[i], context); } obj = arr; break; } } return obj; }