本文整理汇总了Java中net.minecraft.network.PacketBuffer.readVarInt方法的典型用法代码示例。如果您正苦于以下问题:Java PacketBuffer.readVarInt方法的具体用法?Java PacketBuffer.readVarInt怎么用?Java PacketBuffer.readVarInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.network.PacketBuffer
的用法示例。
在下文中一共展示了PacketBuffer.readVarInt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fromBytes
import net.minecraft.network.PacketBuffer; //导入方法依赖的package包/类
@Override
public void fromBytes(ByteBuf buf) {
PacketBuffer buffer = new PacketBuffer(buf);
int x = buffer.readVarInt();
int y = buffer.readVarInt();
int z = buffer.readVarInt();
BlockPos pos = new BlockPos(x, y, z);
int contentLength = buffer.readVarInt();
String content = buffer.readString(contentLength);
int languageId = buffer.readByte();
boolean parsing = buffer.readBoolean();
ScriptLanguage language = ScriptLanguage.values()[languageId];
setContent(content);
setLanguage(language);
setPos(pos);
setParsing(parsing);
}
示例2: readSpawnData
import net.minecraft.network.PacketBuffer; //导入方法依赖的package包/类
@Override
public void readSpawnData(ByteBuf additionalData) {
if(additionalData.readableBytes() == 0)
return;
try {
PacketBuffer buff = new PacketBuffer(additionalData);
if(buff.readBoolean()) {
profile = new GameProfile(buff.readUniqueId(), buff.readString(16));
int l = buff.readVarInt();
int i1 = 0;
for (; i1 < l; ++i1)
{
String s = buff.readString(32767);
String s1 = buff.readString(32767);
if (buff.readBoolean())
{
profile.getProperties().put(s, new Property(s, s1, buff.readString(32767)));
}
else
{
profile.getProperties().put(s, new Property(s, s1));
}
}
final NetworkPlayerInfo info = new NetworkPlayerInfo(profile);
this.entity = new EntityOtherPlayerMP(world, profile) {
@Nullable
protected NetworkPlayerInfo getPlayerInfo()
{
return info;
}
};
this.entity.readFromNBT(buff.readCompoundTag());
/*TF2EventsCommon.THREAD_POOL.submit(()->{
if (profile.getId() != null)
cap.skinType = DefaultPlayerSkin.getSkinType(profile.getId());
Minecraft.getMinecraft().getSkinManager().loadProfileTextures(profile,
new SkinManager.SkinAvailableCallback() {
@Override
public void skinAvailable(Type typeIn, ResourceLocation location,
MinecraftProfileTexture profileTexture) {
if (typeIn == Type.SKIN) {
if (typeIn == Type.SKIN)
cap.skinDisguise = location;
cap.skinType = profileTexture.getMetadata("model");
if (cap.skinType == null)
cap.skinType = "default";
}
}
}, false);
});*/
}
else
this.entity = (EntityLivingBase) EntityList.createEntityFromNBT(buff.readCompoundTag(), this.world);
if(this.entity == null) {
this.setDead();
return;
}
this.entity.deathTime = 0;
this.entity.hurtTime = 0;
this.entity.limbSwingAmount = 0.5f;
this.entity.ticksExisted = 15;
this.entity.limbSwing += this.rand.nextFloat()*10;
this.setSize(this.entity.width, this.entity.height);
this.entity.setPosition(this.posX, this.posY, this.posZ);
//this.prevRotationYaw = this.entity.prevRotationYaw;
//this.rotationYaw = this.entity.rotationYaw;
this.entity.rotationYawHead = this.rotationYaw;
this.entity.renderYawOffset = this.rotationYaw;
this.entity.prevRenderYawOffset = this.rotationYaw;
if (buff.readBoolean()) {
WeaponsCapability.get(this.entity).state = 1;
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}