本文整理汇总了Java中net.minecraftforge.fml.common.network.ByteBufUtils类的典型用法代码示例。如果您正苦于以下问题:Java ByteBufUtils类的具体用法?Java ByteBufUtils怎么用?Java ByteBufUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ByteBufUtils类属于net.minecraftforge.fml.common.network包,在下文中一共展示了ByteBufUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fromBytes
import net.minecraftforge.fml.common.network.ByteBufUtils; //导入依赖的package包/类
@Override
public void fromBytes(ByteBuf buf) {
healingCfg = new FirstAidConfig.ExternalHealing();
healingCfg.allowNaturalRegeneration = buf.readBoolean();
healingCfg.allowOtherHealingItems = buf.readBoolean();
healingCfg.sleepHealing = buf.readFloat();
healingCfg.otherRegenMultiplier = buf.readDouble();
healingCfg.naturalRegenMultiplier = buf.readDouble();
damageCfg = new FirstAidConfig.DamageSystem();
damageCfg.maxHealthHead = buf.readByte();
damageCfg.maxHealthLeftArm = buf.readByte();
damageCfg.maxHealthLeftLeg = buf.readByte();
damageCfg.maxHealthLeftFoot = buf.readByte();
damageCfg.maxHealthBody = buf.readByte();
damageCfg.maxHealthRightArm = buf.readByte();
damageCfg.maxHealthRightLeg = buf.readByte();
damageCfg.maxHealthRightFoot = buf.readByte();
scaleMaxHealth = buf.readBoolean();
playerDamageModel = ByteBufUtils.readTag(buf);
}
示例2: toBytes
import net.minecraftforge.fml.common.network.ByteBufUtils; //导入依赖的package包/类
@Override
public void toBytes(ByteBuf buf)
{
buf.writeInt(pos.getX());
buf.writeInt(pos.getY());
buf.writeInt(pos.getZ());
if (fluidStack != null)
{
buf.writeInt(fluidStack.amount);
ByteBufUtils.writeUTF8String(buf, fluidStack.getFluid().getName());
}
else
{
buf.writeInt(0);
buf.writeBytes(("").getBytes());
}
}
示例3: writeToBuf
import net.minecraftforge.fml.common.network.ByteBufUtils; //导入依赖的package包/类
public void writeToBuf(ByteBuf buf) {
ByteBufUtils.writeUTF8String(buf, offeringPlayerName);
ByteBufUtils.writeUTF8String(buf, offeringPlayerId);
if (providingPosition != null) {
buf.writeBoolean(true);
buf.writeInt(providingPosition.getX());
buf.writeInt(providingPosition.getY());
buf.writeInt(providingPosition.getZ());
buf.writeInt(providingDimensionId);
} else {
buf.writeBoolean(false);
}
if (returningPosition != null) {
buf.writeBoolean(true);
buf.writeInt(returningPosition.getX());
buf.writeInt(returningPosition.getY());
buf.writeInt(returningPosition.getZ());
buf.writeInt(returningDimensionId);
} else {
buf.writeBoolean(false);
}
buf.writeInt(inStock);
buf.writeInt(maxTrades);
buf.writeInt(pendingPayments);
}
示例4: fromBytes
import net.minecraftforge.fml.common.network.ByteBufUtils; //导入依赖的package包/类
@Override
public void fromBytes(ByteBuf buf)
{
pos = ByteBufTools.readBlockPos(buf);
int rows = buf.readInt();
int columns = buf.readInt();
boolean[][] bools = new boolean[rows][columns];
for(int r = 0; r < rows; r++)
{
for(int c = 0; c < columns; c++)
{
bools[r][c] = buf.readBoolean();
}
}
data = bools;
entryName = ByteBufUtils.readUTF8String(buf);
}
示例5: fromBytes
import net.minecraftforge.fml.common.network.ByteBufUtils; //导入依赖的package包/类
@Override
void fromBytes(ByteBuf bytes)
{
int listSize = bytes.readInt();
for (int i = 0; i < listSize; i++) {
String fluidName = ByteBufUtils.readUTF8String(bytes);
int fluidId = bytes.readInt();
fluidIds.put(FluidRegistry.getFluid(fluidName), fluidId);
}
// do we have a defaults list?
if (bytes.isReadable())
{
for (int i = 0; i < listSize; i++)
{
defaultFluids.add(ByteBufUtils.readUTF8String(bytes));
}
}
else
{
FMLLog.getLogger().log(Level.INFO, "Legacy server message contains no default fluid list - there may be problems with fluids");
defaultFluids.clear();
}
}
示例6: fromBytes
import net.minecraftforge.fml.common.network.ByteBufUtils; //导入依赖的package包/类
@Override
public void fromBytes(ByteBuf buf)
{
pos = new BlockPos(buf.readInt(), buf.readInt(), buf.readInt());
int level = buf.readInt();
String fluidId = ByteBufUtils.readUTF8String(buf);
if (level != 0)
{
fluidStack = new FluidStack(FluidRegistry.getFluid(fluidId), level);
}
else
{
fluidStack = null;
}
}
示例7: fromBytes
import net.minecraftforge.fml.common.network.ByteBufUtils; //导入依赖的package包/类
public void fromBytes(ByteBuf buf) {
String s = ByteBufUtils.readUTF8String(buf);
if (s == null) {
return;
}
String[] split = s.split(";");
if (split.length != 6) {
return;
}
try {
energy = Integer.parseInt(split[0]);
maxEnergy = Integer.parseInt(split[1]);
working = Boolean.parseBoolean(split[2]);
bpo = Integer.parseInt(split[3]);
fortune = Integer.parseInt(split[4]);
silk = Boolean.parseBoolean(split[5]);
} catch(Exception e) {
LogUtils.info("Failed to convert client packet info: \"" + s + "\"");
}
}
示例8: toBytes
import net.minecraftforge.fml.common.network.ByteBufUtils; //导入依赖的package包/类
@Override
public void toBytes(ByteBuf buf) {
ByteBufUtils.writeUTF8String(buf, this.playerId);
RezolveByteBufUtils.writeBlockPos(buf, this.entityPos);
ByteBufUtils.writeUTF8String(buf, this.ruleId);
ByteBufUtils.writeUTF8String(buf, this.ruleName);
buf.writeInt(this.mode);
}
示例9: fromBytes
import net.minecraftforge.fml.common.network.ByteBufUtils; //导入依赖的package包/类
@Override
public void fromBytes(ByteBuf buf)
{
text = ByteBufUtils.readUTF8String(buf);
code = ByteBufUtils.readUTF8String(buf);
pos = ByteBufTools.readBlockPos(buf);
}
示例10: fromBytes
import net.minecraftforge.fml.common.network.ByteBufUtils; //导入依赖的package包/类
@Override
public void fromBytes(ByteBuf buf){
this.x=buf.readInt();
this.y=buf.readInt();
this.z=buf.readInt();
this.tag=ByteBufUtils.readTag(buf);
}
示例11: toBytes
import net.minecraftforge.fml.common.network.ByteBufUtils; //导入依赖的package包/类
@Override
public void toBytes(ByteBuf buf) {
if (!this.messageValid)
return;
buf.writeInt(this.cooldown);
buf.writeInt(this.maxCooldown);
ByteBufUtils.writeUTF8String(buf, this.className);
ByteBufUtils.writeUTF8String(buf, this.cooldownFieldName);
ByteBufUtils.writeUTF8String(buf, this.maxCooldownFieldName);
}
示例12: onMessage
import net.minecraftforge.fml.common.network.ByteBufUtils; //导入依赖的package包/类
@Override
public void onMessage(MalmoMessageType messageType, Map<String, String> data)
{
String bufstring = data.get("message");
ByteBuf buf = Unpooled.copiedBuffer(DatatypeConverter.parseBase64Binary(bufstring));
ItemStack itemStack = ByteBufUtils.readItemStack(buf);
if (itemStack != null && itemStack.getItem() != null)
{
accumulateReward(this.params.getDimension(), itemStack);
}
else
{
System.out.println("Error - couldn't understand the itemstack we received.");
}
}
示例13: writeSpawnData
import net.minecraftforge.fml.common.network.ByteBufUtils; //导入依赖的package包/类
@Override
public void writeSpawnData(ByteBuf additionalData)
{
ByteBufUtils.writeItemStack(additionalData, knife);
additionalData.writeFloat(baseDamage);
additionalData.writeFloat(force);
}
示例14: loadFromBuf
import net.minecraftforge.fml.common.network.ByteBufUtils; //导入依赖的package包/类
public static AmadronOfferCustom loadFromBuf(ByteBuf buf) {
AmadronOfferCustom offer = new AmadronOfferCustom(PacketSyncAmadronOffers.getFluidOrItemStack(buf), PacketSyncAmadronOffers.getFluidOrItemStack(buf), ByteBufUtils.readUTF8String(buf), ByteBufUtils.readUTF8String(buf));
if (buf.readBoolean()) {
offer.setProvidingPosition(new BlockPos(buf.readInt(), buf.readInt(), buf.readInt()), buf.readInt());
}
if (buf.readBoolean()) {
offer.setReturningPosition(new BlockPos(buf.readInt(), buf.readInt(), buf.readInt()), buf.readInt());
}
offer.inStock = buf.readInt();
offer.maxTrades = buf.readInt();
offer.pendingPayments = buf.readInt();
return offer;
}
示例15: readFrom
import net.minecraftforge.fml.common.network.ByteBufUtils; //导入依赖的package包/类
@Override
public void readFrom(ByteBuf buf)
{
PacketBuffer buff = new PacketBuffer(buf);
tracks = new Track[buf.readInt()];
for(int i = 0; i < tracks.length; i++)
{
String id = ByteBufUtils.readUTF8String(buf);
String band = ByteBufUtils.readUTF8String(buf);
String md5 = ByteBufUtils.readUTF8String(buf);
TrackFile file = AbcLibrary.getTrack(md5);
tracks[i] = new Track(id, band, md5, file != null ? file.track : null, true);
tracks[i].playing = buf.readBoolean();
tracks[i].playProg = buf.readInt();
int playerCount = buf.readInt();
for(int x = 0; x < playerCount; x++)
{
tracks[i].addPlayer(ByteBufUtils.readUTF8String(buf));
}
playerCount = buf.readInt();
for(int x = 0; x < playerCount; x++)
{
int key = buf.readInt();
int count = buf.readInt();
HashSet<BlockPos> poses = new HashSet<>();
for(int k = 0; k < count; k++)
{
poses.add(buff.readBlockPos());
}
tracks[i].instrumentPlayers.put(key, poses);
}
playerCount = buf.readInt();
for(int x = 0; x < playerCount; x++)
{
tracks[i].zombies.add(buf.readInt());
}
}
}