use of hellfirepvp.astralsorcery.common.util.data.ByteBufUtils in project AstralSorcery by HellFirePvP.
the class PlayerPerkData method read.
public static PlayerPerkData read(PacketBuffer buf, LogicalSide side) {
PlayerPerkData data = new PlayerPerkData();
data.perkExp = buf.readDouble();
data.freePointTokens = ByteBufUtils.readSet(buf, ByteBufUtils::readResourceLocation);
Set<AppliedPerk> appliedPerks = ByteBufUtils.readSet(buf, buffer -> {
ResourceLocation key = ByteBufUtils.readResourceLocation(buffer);
return PerkTree.PERK_TREE.getPerk(side, key).map(AppliedPerk::new).map(perk -> {
perk.read(buffer);
return perk;
}).orElseThrow(() -> new IllegalArgumentException("Unknown perk: " + key));
});
appliedPerks.forEach(appliedPerk -> data.perks.put(appliedPerk.getPerk(), appliedPerk));
return data;
}
use of hellfirepvp.astralsorcery.common.util.data.ByteBufUtils in project AstralSorcery by HellFirePvP.
the class BlockTransmutationSerializer method read.
@Nullable
@Override
public BlockTransmutation read(ResourceLocation recipeId, PacketBuffer buffer) {
List<BlockMatchInformation> matchInformation = ByteBufUtils.readList(buffer, BlockMatchInformation::read);
BlockState output = ByteBufUtils.readBlockState(buffer);
ItemStack display = ByteBufUtils.readItemStack(buffer);
double starlight = buffer.readDouble();
IWeakConstellation cst = ByteBufUtils.readOptional(buffer, ByteBufUtils::readRegistryEntry);
BlockTransmutation tr = new BlockTransmutation(recipeId, output, starlight, cst);
matchInformation.forEach(tr::addInputOption);
tr.setOutputDisplay(display);
return tr;
}
use of hellfirepvp.astralsorcery.common.util.data.ByteBufUtils in project AstralSorcery by HellFirePvP.
the class SimpleAltarRecipe method read.
public static SimpleAltarRecipe read(ResourceLocation recipeId, PacketBuffer buffer) {
AltarType type = ByteBufUtils.readEnumValue(buffer, AltarType.class);
int duration = buffer.readInt();
int starlight = buffer.readInt();
AltarRecipeGrid grid = AltarRecipeGrid.read(buffer);
SimpleAltarRecipe recipe = new SimpleAltarRecipe(recipeId, type, duration, starlight, grid);
ResourceLocation customType = ByteBufUtils.readOptional(buffer, ByteBufUtils::readResourceLocation);
if (customType != null) {
recipe = AltarRecipeTypeHandler.convert(recipe, customType);
recipe.setCustomRecipeType(customType);
}
List<ItemStack> outputs = ByteBufUtils.readList(buffer, ByteBufUtils::readItemStack);
outputs.forEach(recipe::addOutput);
recipe.setFocusConstellation(ByteBufUtils.readOptional(buffer, ByteBufUtils::readRegistryEntry));
ByteBufUtils.readList(buffer, Ingredient::read).forEach(recipe::addRelayInput);
List<AltarRecipeEffect> effects = ByteBufUtils.readList(buffer, ByteBufUtils::readRegistryEntry);
for (AltarRecipeEffect effect : effects) {
recipe.addAltarEffect(effect);
}
recipe.readRecipeSync(buffer);
return recipe;
}
Aggregations