本文整理匯總了Java中io.netty.buffer.ByteBufInputStream.readInt方法的典型用法代碼示例。如果您正苦於以下問題:Java ByteBufInputStream.readInt方法的具體用法?Java ByteBufInputStream.readInt怎麽用?Java ByteBufInputStream.readInt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.netty.buffer.ByteBufInputStream
的用法示例。
在下文中一共展示了ByteBufInputStream.readInt方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: fromBytes
import io.netty.buffer.ByteBufInputStream; //導入方法依賴的package包/類
@Override
public void fromBytes(ByteBuf buf)
{
ByteBufInputStream input = new ByteBufInputStream(buf);
List<Frame> frames = new ArrayList<Frame>();
try
{
this.filename = input.readUTF();
int count = input.readInt();
for (int i = 0; i < count; i++)
{
Frame frame = new Frame();
frame.fromBytes(input);
frames.add(frame);
}
}
catch (IOException e)
{
e.printStackTrace();
}
this.frames = frames;
}
示例2: readData
import io.netty.buffer.ByteBufInputStream; //導入方法依賴的package包/類
@Override
protected void readData(ByteBufInputStream buffer) throws IOException {
tileLocationX = buffer.readInt();
tileLocationY = buffer.readInt();
tileLocationZ = buffer.readInt();
int numTexts = buffer.readInt();
text = new String[numTexts];
for (int i = 0; i < numTexts; i++) {
int stringLength = buffer.readInt();
char[] stringChars = new char[stringLength];
for (int j = 0; j < stringLength; j++) {
stringChars[j] = buffer.readChar();
}
text[i] = new String(stringChars);
}
}
示例3: processData
import io.netty.buffer.ByteBufInputStream; //導入方法依賴的package包/類
@Override
public void processData(EntityPlayer entityPlayer, ByteBufInputStream bbis) throws IOException
{
super.processData(entityPlayer, bbis);
ItemStack itemStack = entityPlayer.getHeldItem();
side = bbis.readInt();
boolean result = entityPlayer.worldObj.getBlock(x, y, z).onBlockActivated(entityPlayer.worldObj, x, y, z, entityPlayer, side, 1.0F, 1.0F, 1.0F);
if (!result) {
if (itemStack != null && itemStack.getItem() instanceof ItemBlock) {
itemStack.tryPlaceItemIntoWorld(entityPlayer, entityPlayer.worldObj, x, y, z, side, 1.0F, 1.0F, 1.0F);
EntityLivingUtil.decrementCurrentSlot(entityPlayer);
}
}
}
示例4: processData
import io.netty.buffer.ByteBufInputStream; //導入方法依賴的package包/類
@Override
public void processData(EntityPlayer entityPlayer, ByteBufInputStream bbis) throws IOException
{
super.processData(entityPlayer, bbis);
World world = entityPlayer.worldObj;
hexColor = bbis.readInt();
TEBase TE = (TEBase) world.getTileEntity(x, y, z);
if (TE != null) {
if (hexColor != 16777215 && !TE.hasAttribute(TE.ATTR_FERTILIZER)) {
TE.addAttribute(TE.ATTR_FERTILIZER, new ItemStack(Items.dye, 1, 15));
EntityLivingUtil.decrementCurrentSlot(entityPlayer);
}
}
}
示例5: processData
import io.netty.buffer.ByteBufInputStream; //導入方法依賴的package包/類
@Override
public void processData(EntityPlayer entityPlayer, ByteBufInputStream bbis) throws IOException
{
int slot = bbis.readInt();
boolean incDmg = bbis.readBoolean();
ItemStack itemStack = entityPlayer.inventory.getStackInSlot(slot);
if (itemStack != null && BlockProperties.toBlock(itemStack).equals(BlockRegistry.blockCarpentersSlope)) {
int maxDmg = BlockCarpentersSlope.slopeType.length - 1;
int itemDmg = itemStack.getItemDamage();
itemDmg += incDmg ? 1 : -1;
if (itemDmg > maxDmg) {
itemDmg = 0;
} else if (itemDmg < 0) {
itemDmg = maxDmg;
}
itemStack.setItemDamage(itemDmg);
}
}
示例6: onServerPacket
import io.netty.buffer.ByteBufInputStream; //導入方法依賴的package包/類
@SubscribeEvent
public void onServerPacket(ServerCustomPacketEvent event) throws IOException
{
ByteBufInputStream bbis = new ByteBufInputStream(event.packet.payload());
EntityPlayer entityPlayer = ((NetHandlerPlayServer) event.handler).playerEntity;
int packetId = bbis.readInt();
if (packetId < packetCarrier.size()) {
try {
ICarpentersPacket packetClass = (ICarpentersPacket) packetCarrier.get(packetId).newInstance();
packetClass.processData(entityPlayer, bbis);
} catch (Exception e) {
e.printStackTrace();
}
} else {
ModLogger.log(Level.WARN, "Encountered out of range packet Id: " + packetId);
}
bbis.close();
}
示例7: readLargeUTF
import io.netty.buffer.ByteBufInputStream; //導入方法依賴的package包/類
/** Read a UTF8 string that could potentially be larger than 64k<br>
* The ByteBufInputStream.readUTF() and writeUTF() calls use the first two bytes of the message
* to encode the length of the string, which limits the string length to 64k.
* This method gets around that limitation by using a four byte header.
* @param bbis ByteBufInputStream we are reading from
* @return the (potentially large) string we read
* @throws IOException
*/
private String readLargeUTF(ByteBufInputStream bbis) throws IOException
{
int length = bbis.readInt();
if (length == 0)
return "";
byte[] data = new byte[length];
int length_read = bbis.read(data, 0, length);
if (length_read != length)
throw new IOException("Failed to read whole message");
return new String(data, "utf-8");
}
示例8: read
import io.netty.buffer.ByteBufInputStream; //導入方法依賴的package包/類
@Override
public void read(ByteBufInputStream byteBuf) throws IOException {
this.ok = byteBuf.readBoolean();
this.minPort = byteBuf.readInt();
this.maxPort = byteBuf.readInt();
this.resources = byteBuf.readUTF();
}
示例9: readData
import io.netty.buffer.ByteBufInputStream; //導入方法依賴的package包/類
@Override
protected void readData(ByteBufInputStream buffer) throws IOException {
entityIdToBeNamed = buffer.readInt();
int nameLength = buffer.readInt();
char[] nameChars = new char[nameLength];
for (int i = 0; i < nameLength; i++) {
nameChars[i] = buffer.readChar();
}
}
示例10: readData
import io.netty.buffer.ByteBufInputStream; //導入方法依賴的package包/類
@Override
protected void readData(ByteBufInputStream buffer) throws IOException {
posX = buffer.readInt();
posY = buffer.readInt();
posZ = buffer.readInt();
int soundLength = buffer.readInt();
char[] soundChars = new char[soundLength];
for (int i = 0; i < soundChars.length; i++) {
soundChars[i] = buffer.readChar();
}
sound = new String(soundChars);
}
示例11: decodeInto
import io.netty.buffer.ByteBufInputStream; //導入方法依賴的package包/類
@Override
public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) throws IOException {
ByteBufInputStream bis = new ByteBufInputStream(buffer);
DataInputStream nbt = new DataInputStream(bis);
entityID = bis.readInt();
tag = NBTHelper.nbtRead(nbt);
}
示例12: decodeInto
import io.netty.buffer.ByteBufInputStream; //導入方法依賴的package包/類
@Override
public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) throws IOException {
ByteBufInputStream bis = new ByteBufInputStream(buffer);
DataInputStream nbt = new DataInputStream(bis);
x = bis.readInt();
y = bis.readInt();
z = bis.readInt();
tag = NBTHelper.nbtRead(nbt);
}
示例13: read
import io.netty.buffer.ByteBufInputStream; //導入方法依賴的package包/類
@Override
public void read(ByteBufInputStream in) throws IOException {
x = in.readInt();
y = in.readInt();
z = in.readInt();
if (payload != null) {
payload.read(in);
}
}
示例14: readData
import io.netty.buffer.ByteBufInputStream; //導入方法依賴的package包/類
protected void readData(ByteBufInputStream buffer) throws IOException {
tileLocationX = buffer.readInt();
tileLocationY = buffer.readInt();
tileLocationZ = buffer.readInt();
int numTexts = buffer.readInt();
text = new String[numTexts];
for (int i = 0; i < numTexts; i++) {
int stringLength = buffer.readInt();
char[] stringChars = new char[stringLength];
for (int j = 0; j < stringLength; j++) {
stringChars[j] = buffer.readChar();
}
text[i] = new String(stringChars);
}
}
示例15: readData
import io.netty.buffer.ByteBufInputStream; //導入方法依賴的package包/類
protected void readData(ByteBufInputStream buffer) throws IOException {
posX = buffer.readInt();
posY = buffer.readInt();
posZ = buffer.readInt();
int soundLength = buffer.readInt();
char[] soundChars = new char[soundLength];
for (int i = 0; i < soundChars.length; i++) {
soundChars[i] = buffer.readChar();
}
sound = new String(soundChars);
}