Java Code Examples for net.minecraft.network.PacketBuffer#readBoolean()

The following examples show how to use net.minecraft.network.PacketBuffer#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: MessageBackpackUpdate.java    From WearableBackpacks with MIT License 6 votes vote down vote up
@Override
public void fromBytes(ByteBuf buf) {
	PacketBuffer buffer = new PacketBuffer(buf);
	try {
		_entityId = buffer.readInt();
		_type = UpdateType.fromByte(buffer.readByte());
		switch (_type) {
			case STACK: _stack = buffer.readItemStack(); break;
			case OPEN: _open = buffer.readBoolean(); break;
			default: throw new RuntimeException("Invalid UpdateType");
		}
	} catch (Exception ex) {
		_entityId = -1;
		_type = UpdateType.INVALID;
		_stack = ItemStack.EMPTY;
		_open = false;
	}
}
 
Example 2
Source File: MetaTileEntityLargeBoiler.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void receiveCustomData(int dataId, PacketBuffer buf) {
    super.receiveCustomData(dataId, buf);
    if (dataId == 100) {
        this.isActive = buf.readBoolean();
    }
}
 
Example 3
Source File: ToggleButtonWidget.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void readUpdateInfo(int id, PacketBuffer buffer) {
    super.readUpdateInfo(id, buffer);
    if (id == 1) {
        this.isPressed = buffer.readBoolean();
    }
}
 
Example 4
Source File: ToggleButtonWidget.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void handleClientAction(int id, PacketBuffer buffer) {
    super.handleClientAction(id, buffer);
    if (id == 1) {
        this.isPressed = buffer.readBoolean();
        setPressedExecutor.apply(isPressed);
    }
}
 
Example 5
Source File: MessageStartPiloting.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@Override
public void fromBytes(ByteBuf buf) {
    PacketBuffer packetBuf = new PacketBuffer(buf);
    posToStartPiloting = new BlockPos(
        packetBuf.readInt(),
        packetBuf.readInt(),
        packetBuf.readInt()
    );
    setPhysicsWrapperEntityToPilot = packetBuf.readBoolean();
    controlType = packetBuf.readEnumValue(ControllerInputType.class);
}
 
Example 6
Source File: SyncableUUID.java    From OpenModsLib with MIT License 5 votes vote down vote up
@Override
public void readFromStream(PacketBuffer stream) {
	if (stream.readBoolean()) {
		this.uuid = stream.readUniqueId();
	} else {
		this.uuid = null;
	}
}
 
Example 7
Source File: FuelRecipeLogic.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void receiveCustomData(int dataId, PacketBuffer buf) {
    if (dataId == 1) {
        this.isActive = buf.readBoolean();
        getMetaTileEntity().getHolder().scheduleChunkForRenderUpdate();
    }
}
 
Example 8
Source File: CraftingSlotWidget.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void readUpdateInfo(int id, PacketBuffer buffer) {
    super.readUpdateInfo(id, buffer);
    if (id == 1) {
        this.canTakeStack = buffer.readBoolean();
    }
}
 
Example 9
Source File: PhysicsObject.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
public void readSpawnData(ByteBuf additionalData) {
    PacketBuffer modifiedBuffer = new PacketBuffer(additionalData);

    setOwnedChunks(new VSChunkClaim(modifiedBuffer.readInt(), modifiedBuffer.readInt(),
        modifiedBuffer.readInt()));

    double posX = modifiedBuffer.readDouble();
    double posY = modifiedBuffer.readDouble();
    double posZ = modifiedBuffer.readDouble();
    double pitch = modifiedBuffer.readDouble();
    double yaw = modifiedBuffer.readDouble();
    double roll = modifiedBuffer.readDouble();

    getWrapperEntity().setPhysicsEntityPositionAndRotation(posX, posY, posZ, pitch, yaw, roll);
    getWrapperEntity().physicsUpdateLastTickPositions();

    setCenterCoord(new Vector(modifiedBuffer));
    loadClaimedChunks();

    getShipRenderer().updateOffsetPos(getReferenceBlockPos());

    getShipTransformationManager().serverBuffer
        .pushMessage(new WrapperPositionMessage(this));

    if (modifiedBuffer.readBoolean()) {
        setPhysicsInfuserPos(modifiedBuffer.readBlockPos());
    }

    markFullyLoaded();
}
 
Example 10
Source File: ByteBufUtils.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static FluidStack readFluidStackDelta(PacketBuffer buf, FluidStack currentFluid) {
    if (buf.readBoolean()) {
        int newFluidAmount = buf.readVarInt();
        if (currentFluid == null) {
            GTLog.logger.error("Received fluid stack delta without acquiring initial state!", new Throwable());
            return null;
        }
        return GTUtility.copyAmount(newFluidAmount, currentFluid);
    } else {
        return readFluidStack(buf);
    }
}
 
Example 11
Source File: SyncableTank.java    From OpenModsLib with MIT License 5 votes vote down vote up
@Override
public void readFromStream(PacketBuffer stream) throws IOException {
	if (stream.readBoolean()) {
		String fluidName = stream.readString(Short.MAX_VALUE);
		Fluid fluid = FluidRegistry.getFluid(fluidName);

		int fluidAmount = stream.readInt();

		this.fluid = new FluidStack(fluid, fluidAmount);
		this.fluid.tag = stream.readCompoundTag();
	} else {
		this.fluid = null;
	}
}
 
Example 12
Source File: SimpleMachineMetaTileEntity.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void receiveInitialSyncData(PacketBuffer buf) {
    super.receiveInitialSyncData(buf);
    this.outputFacing = EnumFacing.VALUES[buf.readByte()];
    this.autoOutputItems = buf.readBoolean();
    this.autoOutputFluids = buf.readBoolean();
}
 
Example 13
Source File: MultiblockControllerBase.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void receiveCustomData(int dataId, PacketBuffer buf) {
    super.receiveCustomData(dataId, buf);
    if (dataId == 400) {
        this.structureFormed = buf.readBoolean();
    }
}
 
Example 14
Source File: MetaTileEntityHolder.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void receiveInitialSyncData(PacketBuffer buf) {
    if (buf.readBoolean()) {
        int metaTileEntityId = buf.readVarInt();
        setMetaTileEntity(GregTechAPI.META_TILE_ENTITY_REGISTRY.getObjectById(metaTileEntityId));
        this.metaTileEntity.receiveInitialSyncData(buf);
        scheduleChunkForRenderUpdate();
        this.needToUpdateLightning = true;
    }
}
 
Example 15
Source File: MemorizedRecipeWidget.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void readUpdateInfo(int id, PacketBuffer buffer) {
    super.readUpdateInfo(id, buffer);
    if (id == 1) this.recipeLocked = buffer.readBoolean();
}
 
Example 16
Source File: TypeRW.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
public Boolean readFromStream(PacketBuffer input) {
	return input.readBoolean();
}
 
Example 17
Source File: AbstractRecipeLogic.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void receiveInitialData(PacketBuffer buf) {
    this.isActive = buf.readBoolean();
}
 
Example 18
Source File: MultiblockControllerBase.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void receiveInitialSyncData(PacketBuffer buf) {
    super.receiveInitialSyncData(buf);
    this.structureFormed = buf.readBoolean();
}
 
Example 19
Source File: MetaTileEntityLargeBoiler.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void receiveInitialSyncData(PacketBuffer buf) {
    super.receiveInitialSyncData(buf);
    this.isActive = buf.readBoolean();
}
 
Example 20
Source File: PlayerParticleData.java    From MiningGadgets with MIT License 4 votes vote down vote up
@Override
public PlayerParticleData read(@Nonnull ParticleType<PlayerParticleData> type, PacketBuffer buf) {
    return new PlayerParticleData(buf.readString(), buf.readDouble(), buf.readDouble(), buf.readDouble(), buf.readFloat(), buf.readFloat(), buf.readFloat(), buf.readFloat(), buf.readFloat(), buf.readBoolean());
}