use of top.theillusivec4.polymorph.api.common.base.IPolymorphCommon in project Polymorph by TheIllusiveC4.
the class PlayerRecipesWidget method selectRecipe.
@Override
public void selectRecipe(ResourceLocation pResourceLocation) {
IPolymorphCommon commonApi = PolymorphApi.common();
Player player = Minecraft.getInstance().player;
if (player != null) {
player.level.getRecipeManager().byKey(pResourceLocation).ifPresent(recipe -> commonApi.getRecipeData(player).ifPresent(recipeData -> recipeData.selectRecipe(recipe)));
}
commonApi.getPacketDistributor().sendPlayerRecipeSelectionC2S(pResourceLocation);
}
use of top.theillusivec4.polymorph.api.common.base.IPolymorphCommon in project Polymorph by TheIllusiveC4.
the class IronFurnacesModule method setup.
@Override
public void setup() {
IPolymorphCommon commonApi = PolymorphApi.common();
commonApi.registerTileEntity2RecipeData(pTileEntity -> {
if (pTileEntity instanceof BlockIronFurnaceTileBase) {
return new IronFurnaceRecipeData((BlockIronFurnaceTileBase) pTileEntity);
}
return null;
});
}
use of top.theillusivec4.polymorph.api.common.base.IPolymorphCommon in project Polymorph by TheIllusiveC4.
the class TomsStorageModule method setup.
@Override
public void setup() {
IPolymorphCommon commonApi = PolymorphApi.common();
commonApi.registerTileEntity2RecipeData(pTileEntity -> {
if (pTileEntity instanceof TileEntityCraftingTerminal) {
return new CraftingTerminalRecipeData((TileEntityCraftingTerminal) pTileEntity);
}
return null;
});
commonApi.registerContainer2TileEntity(pContainer -> {
if (pContainer instanceof ContainerCraftingTerminal) {
return ((AccessorContainerStorageTerminal) pContainer).getTe();
}
return null;
});
}
use of top.theillusivec4.polymorph.api.common.base.IPolymorphCommon in project Polymorph by TheIllusiveC4.
the class PolymorphMod method setup.
private void setup(final FMLCommonSetupEvent pEvent) {
PolymorphNetwork.setup();
MinecraftForge.EVENT_BUS.register(new CommonEventsListener());
IPolymorphCommon commonApi = PolymorphApi.common();
commonApi.registerTileEntity2RecipeData(tileEntity -> {
if (tileEntity instanceof AbstractFurnaceBlockEntity) {
return new FurnaceRecipeData((AbstractFurnaceBlockEntity) tileEntity);
}
return null;
});
commonApi.registerContainer2TileEntity(container -> {
for (Slot inventorySlot : container.slots) {
Container inventory = inventorySlot.container;
if (inventory instanceof BlockEntity) {
return (BlockEntity) inventory;
}
}
return null;
});
PolymorphIntegrations.setup();
}
use of top.theillusivec4.polymorph.api.common.base.IPolymorphCommon in project Polymorph by TheIllusiveC4.
the class StackRecipeData method getListeners.
@Override
public Set<ServerPlayer> getListeners() {
Set<ServerPlayer> players = new HashSet<>();
IPolymorphCommon commonApi = PolymorphApi.common();
commonApi.getServer().ifPresent(server -> {
for (ServerPlayer player : server.getPlayerList().getPlayers()) {
commonApi.getRecipeDataFromItemStack(player.containerMenu).ifPresent(recipeData -> {
if (recipeData == this) {
players.add(player);
}
});
}
});
return players;
}
Aggregations