use of net.minecraft.recipe.RecipeManager in project nbt-crafting by Siphalor.
the class NbtCraftingClient method onInitializeClient.
@Override
public void onInitializeClient() {
ClientLoginNetworking.registerGlobalReceiver(NbtCrafting.PRESENCE_CHANNEL, (client, handler, buf, listenerAdder) -> {
return CompletableFuture.completedFuture(new PacketByteBuf(Unpooled.buffer()));
});
ClientSidePacketRegistry.INSTANCE.register(NbtCrafting.UPDATE_ANVIL_TEXT_S2C_PACKET_ID, (packetContext, packetByteBuf) -> {
if (MinecraftClient.getInstance().currentScreen instanceof AnvilScreen) {
((AnvilScreenAccessor) MinecraftClient.getInstance().currentScreen).getNameField().setText(packetByteBuf.readString());
} else
packetByteBuf.readString();
});
ClientPlayNetworking.registerGlobalReceiver(NbtCrafting.UPDATE_ADVANCED_RECIPES_PACKET_ID, (client, handler, buf, responseSender) -> {
RecipeManager recipeManager = handler.getRecipeManager();
Map<RecipeType<?>, Map<Identifier, Recipe<?>>> recipeMap = ((RecipeManagerAccessor) recipeManager).getRecipes();
recipeMap = new HashMap<>(recipeMap);
int recipeCount = buf.readVarInt();
NbtCrafting.advancedIngredientSerializationEnabled.set(true);
for (int i = 0; i < recipeCount; i++) {
RecipeSerializer<?> serializer = Registry.RECIPE_SERIALIZER.get(buf.readIdentifier());
Identifier id = buf.readIdentifier();
Recipe<?> recipe = serializer.read(id, buf);
Map<Identifier, Recipe<?>> recipeType = recipeMap.computeIfAbsent(recipe.getType(), rt -> new HashMap<>());
recipeType.put(id, recipe);
}
NbtCrafting.advancedIngredientSerializationEnabled.set(false);
((RecipeManagerAccessor) recipeManager).setRecipes(ImmutableMap.copyOf(recipeMap));
});
}
use of net.minecraft.recipe.RecipeManager in project bewitchment by MoriyaShiine.
the class OilCraftingProcessor method setup.
@Override
public void setup(IVariableProvider variables) {
String recipeId = variables.get("recipe").asString();
RecipeManager manager = MinecraftClient.getInstance().world.getRecipeManager();
recipe = (OilRecipe) manager.get(new Identifier(recipeId)).filter(recipe -> recipe.getType().equals(BWRecipeTypes.OIL_RECIPE_TYPE)).orElseThrow(IllegalArgumentException::new);
}
use of net.minecraft.recipe.RecipeManager in project bewitchment by MoriyaShiine.
the class RitualProcessor method setup.
@Override
public void setup(IVariableProvider variables) {
String recipeId = variables.get("recipe").asString();
RecipeManager manager = MinecraftClient.getInstance().world.getRecipeManager();
recipe = (RitualRecipe) manager.get(new Identifier(recipeId)).filter(recipe -> recipe.getType().equals(BWRecipeTypes.RITUAL_RECIPE_TYPE)).orElseThrow(IllegalArgumentException::new);
}
use of net.minecraft.recipe.RecipeManager in project bewitchment by MoriyaShiine.
the class CurseProcessor method setup.
@Override
public void setup(IVariableProvider variables) {
String recipeId = variables.get("recipe").asString();
RecipeManager manager = MinecraftClient.getInstance().world.getRecipeManager();
recipe = (CurseRecipe) manager.get(new Identifier(recipeId)).filter(recipe -> recipe.getType().equals(BWRecipeTypes.CURSE_RECIPE_TYPE)).orElseThrow(IllegalArgumentException::new);
}
use of net.minecraft.recipe.RecipeManager in project bewitchment by MoriyaShiine.
the class IncenseProcessor method setup.
@Override
public void setup(IVariableProvider variables) {
String recipeId = variables.get("recipe").asString();
RecipeManager manager = MinecraftClient.getInstance().world.getRecipeManager();
recipe = (IncenseRecipe) manager.get(new Identifier(recipeId)).filter(recipe -> recipe.getType().equals(BWRecipeTypes.INCENSE_RECIPE_TYPE)).orElseThrow(IllegalArgumentException::new);
}
Aggregations