mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-16 01:55:15 +00:00
Sync recipes on reload (untested)
This commit is contained in:
1 parent
e9c669034e
commit
ea84b87c0d
11 files changed
+314
-11
No files matched your search
@@ -14,8 +14,10 @@ import com.google.common.collect.ImmutableList;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.brew.Brew;
|
||||
import vazkii.botania.api.brew.IBrewContainer;
|
||||
|
||||
@@ -100,4 +102,23 @@ public class RecipeBrew {
|
||||
&& inputs.equals(((RecipeBrew) o).inputs);
|
||||
}
|
||||
|
||||
public void write(PacketBuffer buf) {
|
||||
buf.writeResourceLocation(id);
|
||||
buf.writeString(brew.getKey());
|
||||
buf.writeVarInt(inputs.size());
|
||||
for (Ingredient input : inputs) {
|
||||
input.write(buf);
|
||||
}
|
||||
}
|
||||
|
||||
public static RecipeBrew read(PacketBuffer buf) {
|
||||
ResourceLocation id = buf.readResourceLocation();
|
||||
Brew brew = BotaniaAPI.getBrewFromKey(buf.readString());
|
||||
Ingredient[] inputs = new Ingredient[buf.readVarInt()];
|
||||
for (int i = 0; i < inputs.length; i++) {
|
||||
inputs[i] = Ingredient.read(buf);
|
||||
}
|
||||
return new RecipeBrew(id, brew, inputs);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package vazkii.botania.api.recipe;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -69,4 +70,28 @@ public class RecipeElvenTrade {
|
||||
return outputs;
|
||||
}
|
||||
|
||||
public void write(PacketBuffer buf) {
|
||||
buf.writeResourceLocation(id);
|
||||
buf.writeVarInt(inputs.size());
|
||||
for (Ingredient input : inputs) {
|
||||
input.write(buf);
|
||||
}
|
||||
buf.writeVarInt(outputs.size());
|
||||
for (ItemStack output : outputs) {
|
||||
buf.writeItemStack(output, false);
|
||||
}
|
||||
}
|
||||
|
||||
public static RecipeElvenTrade read(PacketBuffer buf) {
|
||||
ResourceLocation id = buf.readResourceLocation();
|
||||
Ingredient[] inputs = new Ingredient[buf.readVarInt()];
|
||||
for (int i = 0; i < inputs.length; i++) {
|
||||
inputs[i] = Ingredient.read(buf);
|
||||
}
|
||||
ItemStack[] outputs = new ItemStack[buf.readVarInt()];
|
||||
for (int i = 0; i < outputs.length; i++) {
|
||||
outputs[i] = buf.readItemStack();
|
||||
}
|
||||
return new RecipeElvenTrade(id, outputs, inputs);
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
|
||||
@@ -83,5 +84,24 @@ public class RecipeManaInfusion {
|
||||
public int getManaToConsume() {
|
||||
return mana;
|
||||
}
|
||||
|
||||
public void write(PacketBuffer buf) {
|
||||
buf.writeResourceLocation(id);
|
||||
input.write(buf);
|
||||
buf.writeItemStack(output, false);
|
||||
buf.writeVarInt(mana);
|
||||
buf.writeInt(catalystState == null ? -1 : Block.getStateId(catalystState));
|
||||
}
|
||||
|
||||
public static RecipeManaInfusion read(PacketBuffer buf) {
|
||||
ResourceLocation id = buf.readResourceLocation();
|
||||
Ingredient input = Ingredient.read(buf);
|
||||
ItemStack output = buf.readItemStack();
|
||||
int mana = buf.readVarInt();
|
||||
int catalystId = buf.readInt();
|
||||
RecipeManaInfusion ret = new RecipeManaInfusion(id, output, input, mana);
|
||||
ret.setCatalyst(catalystId == -1 ? null : Block.getStateById(catalystId));
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import com.google.common.collect.ImmutableList;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import vazkii.botania.common.core.helper.ItemNBTHelper;
|
||||
@@ -70,4 +71,23 @@ public class RecipePetals {
|
||||
return output;
|
||||
}
|
||||
|
||||
public void write(PacketBuffer buf) {
|
||||
buf.writeResourceLocation(id);
|
||||
buf.writeVarInt(inputs.size());
|
||||
for (Ingredient input : inputs) {
|
||||
input.write(buf);
|
||||
}
|
||||
buf.writeItemStack(output, false);
|
||||
}
|
||||
|
||||
public static RecipePetals read(PacketBuffer buf) {
|
||||
ResourceLocation id = buf.readResourceLocation();
|
||||
Ingredient[] inputs = new Ingredient[buf.readVarInt()];
|
||||
for (int i = 0; i < inputs.length; i++) {
|
||||
inputs[i] = Ingredient.read(buf);
|
||||
}
|
||||
ItemStack output = buf.readItemStack();
|
||||
return new RecipePetals(id, output, inputs);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,10 +13,14 @@ package vazkii.botania.api.recipe;
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.tags.Tag;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import vazkii.botania.api.subtile.TileEntitySpecialFlower;
|
||||
|
||||
public class RecipePureDaisy {
|
||||
@@ -96,4 +100,34 @@ public class RecipePureDaisy {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void write(PacketBuffer buf) {
|
||||
buf.writeResourceLocation(id);
|
||||
if (input instanceof Tag) {
|
||||
buf.writeVarInt(0);
|
||||
buf.writeResourceLocation(((Tag) input).getId());
|
||||
} else if (input instanceof Block) {
|
||||
buf.writeVarInt(1);
|
||||
buf.writeVarInt(Registry.BLOCK.getId((Block) input));
|
||||
} else {
|
||||
buf.writeVarInt(2);
|
||||
buf.writeVarInt(Block.getStateId((BlockState) input));
|
||||
}
|
||||
buf.writeVarInt(Block.getStateId(outputState));
|
||||
buf.writeVarInt(time);
|
||||
}
|
||||
|
||||
public static RecipePureDaisy read(PacketBuffer buf) {
|
||||
ResourceLocation id = buf.readResourceLocation();
|
||||
Object input;
|
||||
switch (buf.readVarInt()) {
|
||||
case 0: input = new BlockTags.Wrapper(buf.readResourceLocation()); break;
|
||||
case 1: input = Registry.BLOCK.getByValue(buf.readVarInt()); break;
|
||||
case 2: input = Block.getStateById(buf.readVarInt()); break;
|
||||
default: throw new RuntimeException("Unknown input discriminator");
|
||||
}
|
||||
BlockState output = Block.getStateById(buf.readVarInt());
|
||||
int time = buf.readVarInt();
|
||||
return new RecipePureDaisy(id, input, output, time);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,23 +11,92 @@
|
||||
package vazkii.botania.api.recipe;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
public class RecipeRuneAltar extends RecipePetals {
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class RecipeRuneAltar {
|
||||
private final ResourceLocation id;
|
||||
private final ItemStack output;
|
||||
private final ImmutableList<Ingredient> inputs;
|
||||
private final int mana;
|
||||
|
||||
public RecipeRuneAltar(ResourceLocation id, ItemStack output, int mana, Ingredient... inputs) {
|
||||
super(id, output, inputs);
|
||||
Preconditions.checkArgument(inputs.length <= 16);
|
||||
Preconditions.checkArgument(mana <= 100000);
|
||||
this.id = id;
|
||||
this.output = output;
|
||||
this.inputs = ImmutableList.copyOf(inputs);
|
||||
this.mana = mana;
|
||||
}
|
||||
|
||||
public boolean matches(IItemHandler inv) {
|
||||
List<Ingredient> ingredientsMissing = new ArrayList<>(inputs);
|
||||
|
||||
for(int i = 0; i < inv.getSlots(); i++) {
|
||||
ItemStack input = inv.getStackInSlot(i);
|
||||
if(input.isEmpty())
|
||||
break;
|
||||
|
||||
int stackIndex = -1;
|
||||
|
||||
for(int j = 0; j < ingredientsMissing.size(); j++) {
|
||||
Ingredient ingr = ingredientsMissing.get(j);
|
||||
if(ingr.test(input)) {
|
||||
stackIndex = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(stackIndex != -1)
|
||||
ingredientsMissing.remove(stackIndex);
|
||||
else return false;
|
||||
}
|
||||
|
||||
return ingredientsMissing.isEmpty();
|
||||
}
|
||||
|
||||
public ResourceLocation getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public List<Ingredient> getInputs() {
|
||||
return inputs;
|
||||
}
|
||||
|
||||
public ItemStack getOutput() {
|
||||
return output;
|
||||
}
|
||||
|
||||
public int getManaUsage() {
|
||||
return mana;
|
||||
}
|
||||
|
||||
public void write(PacketBuffer buf) {
|
||||
buf.writeResourceLocation(id);
|
||||
buf.writeVarInt(inputs.size());
|
||||
for (Ingredient input : inputs) {
|
||||
input.write(buf);
|
||||
}
|
||||
buf.writeItemStack(output, false);
|
||||
buf.writeVarInt(mana);
|
||||
}
|
||||
|
||||
public static RecipeRuneAltar read(PacketBuffer buf) {
|
||||
ResourceLocation id = buf.readResourceLocation();
|
||||
Ingredient[] inputs = new Ingredient[buf.readVarInt()];
|
||||
for (int i = 0; i < inputs.length; i++) {
|
||||
inputs[i] = Ingredient.read(buf);
|
||||
}
|
||||
ItemStack output = buf.readItemStack();
|
||||
int mana = buf.readVarInt();
|
||||
return new RecipeRuneAltar(id, output, mana, inputs);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -136,7 +136,6 @@ public class Botania {
|
||||
ModBrews.init();
|
||||
ModMultiblocks.init();
|
||||
ModCraftingRecipes.init();
|
||||
// todo 1.13 LexiconData.init();
|
||||
|
||||
if(Botania.thaumcraftLoaded) {
|
||||
if(ConfigHandler.COMMON.enableThaumcraftAspects.get()) {
|
||||
@@ -194,8 +193,6 @@ public class Botania {
|
||||
|
||||
// todo 1.13 move everything here to where it belongs
|
||||
private void loadComplete(FMLLoadCompleteEvent event) {
|
||||
LexiconData.postInit();
|
||||
|
||||
int words = 0;
|
||||
for(LexiconEntry entry : BotaniaAPI.getAllEntries())
|
||||
for(LexiconPage page : entry.pages) {
|
||||
|
||||
@@ -5,6 +5,7 @@ import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.resources.IResourceManagerReloadListener;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.network.PacketDistributor;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.recipe.RecipeBrew;
|
||||
import vazkii.botania.api.recipe.RecipeElvenTrade;
|
||||
@@ -13,6 +14,9 @@ import vazkii.botania.api.recipe.RecipePetals;
|
||||
import vazkii.botania.api.recipe.RecipePureDaisy;
|
||||
import vazkii.botania.api.recipe.RecipeRuneAltar;
|
||||
import vazkii.botania.api.recipe.RegisterRecipesEvent;
|
||||
import vazkii.botania.common.lexicon.LexiconData;
|
||||
import vazkii.botania.common.network.PacketHandler;
|
||||
import vazkii.botania.common.network.PacketSyncRecipes;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.HashMap;
|
||||
@@ -44,5 +48,9 @@ public class ReloadListener implements IResourceManagerReloadListener {
|
||||
BotaniaAPI.elvenTradeRecipes = ImmutableMap.copyOf(elvenTrade);
|
||||
BotaniaAPI.petalRecipes = ImmutableMap.copyOf(apothecary);
|
||||
BotaniaAPI.runeAltarRecipes = ImmutableMap.copyOf(runeAltar);
|
||||
PacketHandler.HANDLER.send(PacketDistributor.ALL.noArg(), new PacketSyncRecipes(brew, elvenTrade, manaInfusion,
|
||||
apothecary, pureDaisy, runeAltar));
|
||||
|
||||
LexiconData.reload();
|
||||
}
|
||||
}
|
||||
@@ -299,7 +299,10 @@ public final class LexiconData {
|
||||
public static LexiconEntry bcIntegration;
|
||||
public static LexiconEntry banners;
|
||||
|
||||
public static void init() {
|
||||
public static void reload() {
|
||||
BotaniaAPI.getAllCategories().clear();
|
||||
BotaniaAPI.getAllEntries().clear();
|
||||
|
||||
BotaniaAPI.addCategory(BotaniaAPI.categoryBasics = new BLexiconCategory(LibLexicon.CATEGORY_BASICS, 9));
|
||||
BotaniaAPI.addCategory(BotaniaAPI.categoryMana = new BLexiconCategory(LibLexicon.CATEGORY_MANA, 5));
|
||||
BotaniaAPI.addCategory(BotaniaAPI.categoryGenerationFlowers = new BLexiconCategory(LibLexicon.CATEGORY_GENERATION_FLOWERS, 5));
|
||||
@@ -1409,9 +1412,7 @@ public final class LexiconData {
|
||||
bcIntegration = new CompatLexiconEntry(LibLexicon.MISC_BC_INTEGRATION, categoryMisc, "BuildCraft");
|
||||
bcIntegration.setLexiconPages(new PageText("0")).setIcon(new ItemStack(Items.REDSTONE));
|
||||
}
|
||||
}
|
||||
|
||||
public static void postInit() {
|
||||
if (Botania.thaumcraftLoaded) {
|
||||
tcIntegration = new CompatLexiconEntry(LibLexicon.MISC_TC_INTEGRATION, BotaniaAPI.categoryMisc, "Thaumcraft");
|
||||
|
||||
@@ -1420,13 +1421,13 @@ public final class LexiconData {
|
||||
new PageCraftingRecipe("2", ModCraftingRecipes.recipeHelmetOfRevealing), new PageText("3"),
|
||||
new PageManaInfusionRecipe("4", ModManaInfusionRecipes.manaInkwellRecipe), new PageText("5"),
|
||||
new PageBrew(ModBrewRecipes.warpWardBrew, "6a", "6b"))
|
||||
.setIcon(new ItemStack(ModItems.manaInkwell));
|
||||
.setIcon(new ItemStack(ModItems.manaInkwell));
|
||||
else
|
||||
tcIntegration.setLexiconPages(new PageText("0"), new PageText("1"),
|
||||
new PageCraftingRecipe("2", ModCraftingRecipes.recipeHelmetOfRevealing), new PageText("3"),
|
||||
new PageManaInfusionRecipe("4", ModManaInfusionRecipes.manaInkwellRecipe),
|
||||
new PageBrew(ModBrewRecipes.warpWardBrew, "6a", "6b"))
|
||||
.setIcon(new ItemStack(ModItems.manaInkwell));
|
||||
.setIcon(new ItemStack(ModItems.manaInkwell));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.ServerWorld;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.ServerWorld;
|
||||
@@ -15,9 +16,12 @@ import net.minecraftforge.fml.network.PacketDistributor;
|
||||
import net.minecraftforge.fml.network.simple.SimpleChannel;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public final class PacketHandler {
|
||||
private static final String PROTOCOL = "1";
|
||||
private static final SimpleChannel HANDLER = NetworkRegistry.newSimpleChannel(
|
||||
public static final SimpleChannel HANDLER = NetworkRegistry.newSimpleChannel(
|
||||
new ResourceLocation(LibMisc.MOD_ID, "chan"),
|
||||
() -> PROTOCOL,
|
||||
PROTOCOL::equals,
|
||||
@@ -31,6 +35,7 @@ public final class PacketHandler {
|
||||
HANDLER.registerMessage(id++, PacketDodge.class, PacketDodge::encode, PacketDodge::decode, PacketDodge::handle);
|
||||
HANDLER.registerMessage(id++, PacketJump.class, PacketJump::encode, PacketJump::decode, PacketJump::handle);
|
||||
HANDLER.registerMessage(id++, PacketItemAge.class, PacketItemAge::encode, PacketItemAge::decode, PacketItemAge::handle);
|
||||
HANDLER.registerMessage(id++, PacketSyncRecipes.class, PacketSyncRecipes::encode, PacketSyncRecipes::decode, PacketSyncRecipes::handle);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,6 +45,7 @@ public final class PacketHandler {
|
||||
if(world instanceof ServerWorld) {
|
||||
ServerWorld ws = (ServerWorld) world;
|
||||
|
||||
// todo 1.14 this sends duplicates
|
||||
for (ServerPlayerEntity playerMP : ws.getPlayers()) {
|
||||
if (playerMP.getDistanceSq(pos.getX(), pos.getY(), pos.getZ()) < 64 * 64) {
|
||||
HANDLER.send(PacketDistributor.TRACKING_CHUNK.with(() -> world.getChunkAt(pos)), toSend);
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
package vazkii.botania.common.network;
|
||||
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.network.NetworkEvent;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.recipe.RecipeBrew;
|
||||
import vazkii.botania.api.recipe.RecipeElvenTrade;
|
||||
import vazkii.botania.api.recipe.RecipeManaInfusion;
|
||||
import vazkii.botania.api.recipe.RecipePetals;
|
||||
import vazkii.botania.api.recipe.RecipePureDaisy;
|
||||
import vazkii.botania.api.recipe.RecipeRuneAltar;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class PacketSyncRecipes {
|
||||
private Map<ResourceLocation, RecipeBrew> brew;
|
||||
private Map<ResourceLocation, RecipeElvenTrade> elven;
|
||||
private Map<ResourceLocation, RecipeManaInfusion> manaInfusion;
|
||||
private Map<ResourceLocation, RecipePetals> petal;
|
||||
private Map<ResourceLocation, RecipePureDaisy> pureDaisy;
|
||||
private Map<ResourceLocation, RecipeRuneAltar> runeAltar;
|
||||
|
||||
public PacketSyncRecipes(Map<ResourceLocation, RecipeBrew> brew, Map<ResourceLocation, RecipeElvenTrade> elven, Map<ResourceLocation, RecipeManaInfusion> manaInfusion, Map<ResourceLocation, RecipePetals> petal, Map<ResourceLocation, RecipePureDaisy> pureDaisy, Map<ResourceLocation, RecipeRuneAltar> runeAltar) {
|
||||
this.brew = brew;
|
||||
this.elven = elven;
|
||||
this.manaInfusion = manaInfusion;
|
||||
this.petal = petal;
|
||||
this.pureDaisy = pureDaisy;
|
||||
this.runeAltar = runeAltar;
|
||||
}
|
||||
|
||||
public void encode(PacketBuffer buf) {
|
||||
buf.writeVarInt(brew.size());
|
||||
for (RecipeBrew recipe : brew.values()) {
|
||||
recipe.write(buf);
|
||||
}
|
||||
buf.writeVarInt(elven.size());
|
||||
for (RecipeElvenTrade recipe : elven.values()) {
|
||||
recipe.write(buf);
|
||||
}
|
||||
buf.writeVarInt(manaInfusion.size());
|
||||
for (RecipeManaInfusion recipe : manaInfusion.values()) {
|
||||
recipe.write(buf);
|
||||
}
|
||||
buf.writeVarInt(petal.size());
|
||||
for (RecipePetals recipe : petal.values()) {
|
||||
recipe.write(buf);
|
||||
}
|
||||
buf.writeVarInt(pureDaisy.size());
|
||||
for (RecipePureDaisy recipe : pureDaisy.values()) {
|
||||
recipe.write(buf);
|
||||
}
|
||||
buf.writeVarInt(runeAltar.size());
|
||||
for (RecipeRuneAltar recipe : runeAltar.values()) {
|
||||
recipe.write(buf);
|
||||
}
|
||||
}
|
||||
|
||||
public static PacketSyncRecipes decode(PacketBuffer buf) {
|
||||
int brewCount = buf.readVarInt();
|
||||
Map<ResourceLocation, RecipeBrew> brew = Stream.generate(() -> RecipeBrew.read(buf))
|
||||
.limit(brewCount)
|
||||
.collect(Collectors.toMap(RecipeBrew::getId, r -> r));
|
||||
int elvenCount = buf.readVarInt();
|
||||
Map<ResourceLocation, RecipeElvenTrade> elven = Stream.generate(() -> RecipeElvenTrade.read(buf))
|
||||
.limit(elvenCount)
|
||||
.collect(Collectors.toMap(RecipeElvenTrade::getId, r -> r));
|
||||
int manaInfusionCount = buf.readVarInt();
|
||||
Map<ResourceLocation, RecipeManaInfusion> manaInfusion = Stream.generate(() -> RecipeManaInfusion.read(buf))
|
||||
.limit(manaInfusionCount)
|
||||
.collect(Collectors.toMap(RecipeManaInfusion::getId, r -> r));
|
||||
int petalCount = buf.readVarInt();
|
||||
Map<ResourceLocation, RecipePetals> petal = Stream.generate(() -> RecipePetals.read(buf))
|
||||
.limit(petalCount)
|
||||
.collect(Collectors.toMap(RecipePetals::getId, r -> r));
|
||||
int pureDaisyCount = buf.readVarInt();
|
||||
Map<ResourceLocation, RecipePureDaisy> pureDaisy = Stream.generate(() -> RecipePureDaisy.read(buf))
|
||||
.limit(pureDaisyCount)
|
||||
.collect(Collectors.toMap(RecipePureDaisy::getId, r -> r));
|
||||
int runeCount = buf.readVarInt();
|
||||
Map<ResourceLocation, RecipeRuneAltar> rune = Stream.generate(() -> RecipeRuneAltar.read(buf))
|
||||
.limit(runeCount)
|
||||
.collect(Collectors.toMap(RecipeRuneAltar::getId, r -> r));
|
||||
return new PacketSyncRecipes(brew, elven, manaInfusion, petal, pureDaisy, rune);
|
||||
}
|
||||
|
||||
public void handle(Supplier<NetworkEvent.Context> ctx) {
|
||||
ctx.get().enqueueWork(() -> {
|
||||
BotaniaAPI.brewRecipes = brew;
|
||||
BotaniaAPI.elvenTradeRecipes = elven;
|
||||
BotaniaAPI.manaInfusionRecipes = manaInfusion;
|
||||
BotaniaAPI.petalRecipes = petal;
|
||||
BotaniaAPI.pureDaisyRecipes = pureDaisy;
|
||||
BotaniaAPI.runeAltarRecipes = runeAltar;
|
||||
});
|
||||
ctx.get().setPacketHandled(true);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user