|
| 1 | +/* |
| 2 | + * Copyright (c) 2024 TeamMoeg |
| 3 | + * |
| 4 | + * This file is part of Caupona. |
| 5 | + * |
| 6 | + * Caupona is free software: you can redistribute it and/or modify |
| 7 | + * it under the terms of the GNU General Public License as published by |
| 8 | + * the Free Software Foundation, version 3. |
| 9 | + * |
| 10 | + * Caupona is distributed in the hope that it will be useful, |
| 11 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | + * GNU General Public License for more details. |
| 14 | + * |
| 15 | + * Specially, we allow this software to be used alongside with closed source software Minecraft(R) and Forge or other modloader. |
| 16 | + * Any mods or plugins can also use apis provided by forge or com.teammoeg.caupona.api without using GPL or open source. |
| 17 | + * |
| 18 | + * You should have received a copy of the GNU General Public License |
| 19 | + * along with Caupona. If not, see <https://www.gnu.org/licenses/>. |
| 20 | + */ |
| 21 | + |
| 22 | +package com.teammoeg.caupona.compat.top.providers; |
| 23 | + |
| 24 | +import java.util.ArrayList; |
| 25 | +import java.util.List; |
| 26 | + |
| 27 | +import com.teammoeg.caupona.blocks.pan.PanBlockEntity; |
| 28 | +import com.teammoeg.caupona.blocks.pot.StewPotBlockEntity; |
| 29 | +import com.teammoeg.caupona.compat.top.TOPRegister; |
| 30 | +import mcjty.theoneprobe.api.IProbeHitData; |
| 31 | +import mcjty.theoneprobe.api.IProbeInfo; |
| 32 | +import mcjty.theoneprobe.api.IProbeInfoProvider; |
| 33 | +import mcjty.theoneprobe.api.ProbeMode; |
| 34 | +import net.minecraft.resources.ResourceLocation; |
| 35 | +import net.minecraft.world.entity.player.Player; |
| 36 | +import net.minecraft.world.item.ItemStack; |
| 37 | +import net.minecraft.world.item.Items; |
| 38 | +import net.minecraft.world.level.Level; |
| 39 | +import net.minecraft.world.level.block.state.BlockState; |
| 40 | +import net.neoforged.neoforge.items.ItemStackHandler; |
| 41 | + |
| 42 | +public class PanProvider implements IProbeInfoProvider { |
| 43 | + |
| 44 | + @Override |
| 45 | + public void addProbeInfo(ProbeMode mode, IProbeInfo info, Player player, Level level, BlockState state, IProbeHitData hitResult) { |
| 46 | + if(level.getBlockEntity(hitResult.getPos()) instanceof PanBlockEntity entity) { |
| 47 | + if(player.isShiftKeyDown()) { |
| 48 | + ItemStackHandler inventory=entity.getInv(); |
| 49 | + List<ItemStack> inputs=new ArrayList<>(); |
| 50 | + for(int i=0;i<inventory.getSlots();i++) { |
| 51 | + if(!inventory.getStackInSlot(i).isEmpty()) |
| 52 | + inputs.add(inventory.getStackInSlot(i)); |
| 53 | + } |
| 54 | + if(!inputs.isEmpty()) { |
| 55 | + IProbeInfo layout=info.horizontal(info.defaultLayoutStyle().borderColor(0x88ffffff).spacing(0)); |
| 56 | + inputs.forEach(layout::item); |
| 57 | + } |
| 58 | + } |
| 59 | + if(entity.rsstate) { |
| 60 | + info.item(new ItemStack(Items.REDSTONE_TORCH)); |
| 61 | + } |
| 62 | + info.progress(entity.process, entity.processMax); |
| 63 | + if(entity.processMax>0) { |
| 64 | + if(player.isShiftKeyDown()){ |
| 65 | + if(entity.preout!=null) { |
| 66 | + info.item(entity.preout); |
| 67 | + } |
| 68 | + } |
| 69 | + } |
| 70 | + |
| 71 | + } |
| 72 | + } |
| 73 | + |
| 74 | + |
| 75 | + @Override |
| 76 | + public ResourceLocation getID() { |
| 77 | + return TOPRegister.idForBlock("pan"); |
| 78 | + } |
| 79 | + |
| 80 | +} |
0 commit comments