Search in sources :

Example 1 with VersionUtil

use of com.yogpc.qp.version.VersionUtil in project QuarryPlus by Kotori316.

the class QuarryPlus method message.

/**
 * Message key must be either {@code IMC_RemoveRecipe} or {@code IMC_AddRecipe}.
 * Message value must be NBTTag.
 *
 * @param event event
 */
@Mod.EventHandler
public void message(FMLInterModComms.IMCEvent event) {
    event.getMessages().forEach(imcMessage -> {
        NBTTagCompound nbtValue = imcMessage.getNBTValue();
        Function<NBTTagCompound, ItemStack> toStack = VersionUtil::fromNBTTag;
        if (Optionals.IMC_Remove.equals(imcMessage.key)) {
            WorkbenchRecipes.removeRecipe(ItemDamage.apply(toStack.apply(nbtValue)));
        } else if (Optionals.IMC_Add.equals(imcMessage.key)) {
            Function<ItemStack, IntFunction<ItemStack>> toFunc = stack -> (IntFunction<ItemStack>) integer -> ItemHandlerHelper.copyStackWithSize(stack, VersionUtil.getCount(stack) * integer);
            NBTTagList list = nbtValue.getTagList(Optionals.IMC_Add, Constants.NBT.TAG_COMPOUND);
            ItemDamage result = ItemDamage.apply(toStack.apply(list.getCompoundTagAt(0)));
            List<IntFunction<ItemStack>> functionList = VersionUtil.nbtListStream(list).skip(1).map(toStack.andThen(toFunc)).collect(Collectors.toList());
            WorkbenchRecipes.addListRecipe(result, nbtValue.getInteger(Optionals.IMC_Energy), functionList, true, WorkbenchRecipes.UnitRF());
        }
    });
}
Also used : TileAdvQuarry(com.yogpc.qp.tile.TileAdvQuarry) VersionUtil(com.yogpc.qp.version.VersionUtil) Item(net.minecraft.item.Item) ModelRegistryEvent(net.minecraftforge.client.event.ModelRegistryEvent) Constants(net.minecraftforge.common.util.Constants) TileBreaker(com.yogpc.qp.tile.TileBreaker) FMLCommonHandler(net.minecraftforge.fml.common.FMLCommonHandler) TileQuarry(com.yogpc.qp.tile.TileQuarry) ForgeChunkManager(net.minecraftforge.common.ForgeChunkManager) TileWorkbench(com.yogpc.qp.tile.TileWorkbench) VersionDiff(com.yogpc.qp.version.VersionDiff) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) ForgeVersion(net.minecraftforge.common.ForgeVersion) TileMiningWell(com.yogpc.qp.tile.TileMiningWell) NBTTagList(net.minecraft.nbt.NBTTagList) Block(net.minecraft.block.Block) Side(net.minecraftforge.fml.relauncher.Side) RegistryEvent(net.minecraftforge.event.RegistryEvent) SidedProxy(net.minecraftforge.fml.common.SidedProxy) QuarryPlusI(com.yogpc.qp.QuarryPlusI) BuildcraftHelper(com.yogpc.qp.compat.BuildcraftHelper) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) WorldEvent(net.minecraftforge.event.world.WorldEvent) Sprites(com.yogpc.qp.render.Sprites) TilePlacer(com.yogpc.qp.tile.TilePlacer) GuiFactory(com.yogpc.qp.gui.GuiFactory) TileSolidQuarry(com.yogpc.qp.tile.TileSolidQuarry) ItemDamage(com.yogpc.qp.tile.ItemDamage) Collectors(java.util.stream.Collectors) WorkbenchRecipes(com.yogpc.qp.tile.WorkbenchRecipes) List(java.util.List) ItemTool(com.yogpc.qp.item.ItemTool) Logger(org.apache.logging.log4j.Logger) FMLInterModComms(net.minecraftforge.fml.common.event.FMLInterModComms) ModAPIManager(net.minecraftforge.fml.common.ModAPIManager) TileLaser(com.yogpc.qp.tile.TileLaser) TileMarker(com.yogpc.qp.tile.TileMarker) PacketHandler(com.yogpc.qp.packet.PacketHandler) Blocks(net.minecraft.init.Blocks) TilePump(com.yogpc.qp.tile.TilePump) GuiHandler(com.yogpc.qp.gui.GuiHandler) GameRegistry(net.minecraftforge.fml.common.registry.GameRegistry) Function(java.util.function.Function) ItemStack(net.minecraft.item.ItemStack) TileRefinery(com.yogpc.qp.tile.TileRefinery) ItemHandlerHelper(net.minecraftforge.items.ItemHandlerHelper) FMLFingerprintViolationEvent(net.minecraftforge.fml.common.event.FMLFingerprintViolationEvent) TileAdvPump(com.yogpc.qp.tile.TileAdvPump) FMLPreInitializationEvent(net.minecraftforge.fml.common.event.FMLPreInitializationEvent) Mod(net.minecraftforge.fml.common.Mod) FMLInitializationEvent(net.minecraftforge.fml.common.event.FMLInitializationEvent) ModelLoader(net.minecraftforge.client.model.ModelLoader) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) IntFunction(java.util.function.IntFunction) Items(net.minecraft.init.Items) TileExpPump(com.yogpc.qp.tile.TileExpPump) MinecraftForge(net.minecraftforge.common.MinecraftForge) NetworkRegistry(net.minecraftforge.fml.common.network.NetworkRegistry) TileBookMover(com.yogpc.qp.tile.TileBookMover) Launch(net.minecraft.launchwrapper.Launch) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) LogManager(org.apache.logging.log4j.LogManager) NBTTagList(net.minecraft.nbt.NBTTagList) Function(java.util.function.Function) IntFunction(java.util.function.IntFunction) ItemDamage(com.yogpc.qp.tile.ItemDamage) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) NBTTagList(net.minecraft.nbt.NBTTagList) List(java.util.List) ItemStack(net.minecraft.item.ItemStack)

Aggregations

QuarryPlusI (com.yogpc.qp.QuarryPlusI)1 BuildcraftHelper (com.yogpc.qp.compat.BuildcraftHelper)1 GuiFactory (com.yogpc.qp.gui.GuiFactory)1 GuiHandler (com.yogpc.qp.gui.GuiHandler)1 ItemTool (com.yogpc.qp.item.ItemTool)1 PacketHandler (com.yogpc.qp.packet.PacketHandler)1 Sprites (com.yogpc.qp.render.Sprites)1 ItemDamage (com.yogpc.qp.tile.ItemDamage)1 TileAdvPump (com.yogpc.qp.tile.TileAdvPump)1 TileAdvQuarry (com.yogpc.qp.tile.TileAdvQuarry)1 TileBookMover (com.yogpc.qp.tile.TileBookMover)1 TileBreaker (com.yogpc.qp.tile.TileBreaker)1 TileExpPump (com.yogpc.qp.tile.TileExpPump)1 TileLaser (com.yogpc.qp.tile.TileLaser)1 TileMarker (com.yogpc.qp.tile.TileMarker)1 TileMiningWell (com.yogpc.qp.tile.TileMiningWell)1 TilePlacer (com.yogpc.qp.tile.TilePlacer)1 TilePump (com.yogpc.qp.tile.TilePump)1 TileQuarry (com.yogpc.qp.tile.TileQuarry)1 TileRefinery (com.yogpc.qp.tile.TileRefinery)1