List of usage examples for io.netty.buffer ByteBuf readByte
public abstract byte 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:appeng.entity.EntityTinyTNTPrimed.java
License:Open Source License
@Override public void readSpawnData(final ByteBuf data) { this.setFuse(data.readByte()); ; }
From source file:appeng.facade.FacadeContainer.java
License:Open Source License
@Override public boolean readFromStream(final ByteBuf out) throws IOException { final int facadeSides = out.readByte(); boolean changed = false; final int[] ids = new int[2]; for (int x = 0; x < this.facades; x++) { final AEPartLocation side = AEPartLocation.fromOrdinal(x); final int ix = (1 << x); if ((facadeSides & ix) == ix) { ids[0] = out.readInt();/*from w w w . j a v a 2 s . c o m*/ ids[1] = out.readInt(); ids[0] = Math.abs(ids[0]); Optional<Item> maybeFacadeItem = AEApi.instance().definitions().items().facade().maybeItem(); if (maybeFacadeItem.isPresent()) { final ItemFacade ifa = (ItemFacade) maybeFacadeItem.get(); final ItemStack facade = ifa.createFromIDs(ids); if (facade != null) { changed = changed || this.storage.getFacade(x) == null; this.storage.setFacade(x, ifa.createPartFromItemStack(facade, side)); } } } else { changed = changed || this.storage.getFacade(x) != null; this.storage.setFacade(x, null); } } return changed; }
From source file:appeng.helpers.Splotch.java
License:Open Source License
public Splotch(final ByteBuf data) { this.pos = data.readByte(); final int val = data.readByte(); this.side = EnumFacing.VALUES[val & 0x07]; this.color = AEColor.values()[(val >> 3) & 0x0F]; this.lumen = ((val >> 7) & 0x01) > 0; }
From source file:appeng.parts.CableBusContainer.java
License:Open Source License
public boolean readFromStream(final ByteBuf data) throws IOException { final byte sides = data.readByte(); boolean updateBlock = false; for (int x = 0; x < 7; x++) { AEPartLocation side = AEPartLocation.fromOrdinal(x); if (((sides & (1 << x)) == (1 << x))) { IPart p = this.getPart(side); final short itemID = data.readShort(); final short dmgValue = data.readShort(); final Item myItem = Item.getItemById(itemID); final ItemStack current = p != null ? p.getItemStack(PartItemStack.NETWORK) : null; if (current != null && current.getItem() == myItem && current.getItemDamage() == dmgValue) { if (p.readFromStream(data)) { updateBlock = true;//from ww w . j a v a 2 s.co m } } else { this.removePart(side, false); side = this.addPart(new ItemStack(myItem, 1, dmgValue), side, null, null); if (side != null) { p = this.getPart(side); p.readFromStream(data); } else { throw new IllegalStateException("Invalid Stream For CableBus Container."); } } } else if (this.getPart(side) != null) { this.removePart(side, false); } } if (this.getFacadeContainer().readFromStream(data)) { return true; } return updateBlock; }
From source file:appeng.parts.networking.PartCable.java
License:Open Source License
@Override public boolean readFromStream(final ByteBuf data) throws IOException { int cs = data.readByte(); final EnumSet<AEPartLocation> myC = this.getConnections().clone(); final boolean wasPowered = this.powered; this.powered = false; boolean channelsChanged = false; for (final AEPartLocation d : AEPartLocation.values()) { if (d == AEPartLocation.INTERNAL) { final int id = 1 << d.ordinal(); if (id == (cs & id)) { this.powered = true; }// w w w . j a va2s .co m } else { boolean conOnSide = (cs & (1 << d.ordinal())) != 0; if (conOnSide) { this.getConnections().add(d); } else { this.getConnections().remove(d); } int ch = 0; // Only read channels if there's a part on this side or a cable connection // This works only because cables are always read *last* from the packet update for // a cable bus if (conOnSide || getHost().getPart(d) != null) { ch = ((int) data.readByte()) & 0xFF; } if (ch != this.getChannelsOnSide(d.ordinal())) { channelsChanged = true; this.setChannelsOnSide(d.ordinal(), ch); } } } return !myC.equals(this.getConnections()) || wasPowered != this.powered || channelsChanged; }
From source file:appeng.parts.PartBasicState.java
License:Open Source License
@Override public boolean readFromStream(final ByteBuf data) throws IOException { final boolean eh = super.readFromStream(data); final int old = this.getClientFlags(); this.setClientFlags(data.readByte()); return eh || old != this.getClientFlags(); }
From source file:appeng.parts.reporting.AbstractPartReporting.java
License:Open Source License
@Override public boolean readFromStream(final ByteBuf data) throws IOException { super.readFromStream(data); final int oldFlags = this.getClientFlags(); this.clientFlags = data.readByte(); this.spin = (byte) (this.getClientFlags() & 3); if (this.getClientFlags() == oldFlags) { return false; }/*from ww w. j a v a 2 s . c o m*/ return true; }
From source file:appeng.parts.reporting.PartMonitor.java
License:Open Source License
@Override public boolean readFromStream(ByteBuf data) throws IOException { super.readFromStream(data); int oldFlags = this.clientFlags; this.clientFlags = data.readByte(); this.spin = (byte) (this.clientFlags & 3); if (this.clientFlags == oldFlags) { return false; }/*www.jav a 2 s .c o m*/ return true; }