use of top.theillusivec4.polymorph.common.integration.AbstractCompatibilityModule in project Polymorph by TheIllusiveC4.
the class PolymorphNetwork method handlePlayerSelect.
private static void handlePlayerSelect(MinecraftServer pServer, ServerPlayerEntity pPlayer, ServerPlayNetworkHandler pHandler, PacketByteBuf pBuf, PacketSender pResponseSender) {
Identifier identifier = pBuf.readIdentifier();
pServer.execute(() -> {
ScreenHandler screenHandler = pPlayer.currentScreenHandler;
pPlayer.world.getRecipeManager().get(identifier).ifPresent(recipe -> {
PolymorphApi.common().getRecipeData(pPlayer).ifPresent(recipeData -> recipeData.selectRecipe(recipe));
for (AbstractCompatibilityModule integration : PolymorphIntegrations.get()) {
if (integration.selectRecipe(screenHandler, recipe)) {
return;
}
}
screenHandler.onContentChanged(pPlayer.getInventory());
if (screenHandler instanceof ForgingScreenHandler) {
((ForgingScreenHandler) screenHandler).updateResult();
}
});
});
}
use of top.theillusivec4.polymorph.common.integration.AbstractCompatibilityModule in project Polymorph by TheIllusiveC4.
the class CPacketPersistentRecipeSelection method handle.
public static void handle(CPacketPersistentRecipeSelection pPacket, Supplier<NetworkEvent.Context> pContext) {
pContext.get().enqueueWork(() -> {
ServerPlayer sender = pContext.get().getSender();
if (sender != null) {
Level world = sender.getCommandSenderWorld();
Optional<? extends Recipe<?>> maybeRecipe = world.getRecipeManager().byKey(pPacket.recipe);
maybeRecipe.ifPresent(recipe -> {
AbstractContainerMenu container = sender.containerMenu;
PolymorphApi.common().getRecipeDataFromTileEntity(container).ifPresent(recipeData -> {
recipeData.selectRecipe(recipe);
for (AbstractCompatibilityModule integration : PolymorphIntegrations.get()) {
if (integration.selectRecipe(recipeData.getOwner(), recipe) || integration.selectRecipe(container, recipe)) {
return;
}
}
});
});
}
});
pContext.get().setPacketHandled(true);
}
Aggregations