Skip to content

Commit

Permalink
forget to register
Browse files Browse the repository at this point in the history
  • Loading branch information
khjxiaogu committed Sep 23, 2024
1 parent 6418384 commit 56a671f
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public static Object register(ITheOneProbe top) {
top.registerProvider(new GravyBoatProvider());
top.registerProvider(new LoafProvider());
top.registerProvider(new PotProvider());
top.registerProvider(new PanProvider());
top.registerProvider(new StoveProvider());
top.registerProvider(new WolfProvider());
top.registerProvider(new InfProvider());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* Copyright (c) 2024 TeamMoeg
*
* This file is part of Caupona.
*
* Caupona is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* Caupona is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* Specially, we allow this software to be used alongside with closed source software Minecraft(R) and Forge or other modloader.
* Any mods or plugins can also use apis provided by forge or com.teammoeg.caupona.api without using GPL or open source.
*
* You should have received a copy of the GNU General Public License
* along with Caupona. If not, see <https://www.gnu.org/licenses/>.
*/

package com.teammoeg.caupona.compat.top.providers;

import java.util.ArrayList;
import java.util.List;

import com.teammoeg.caupona.blocks.pan.PanBlockEntity;
import com.teammoeg.caupona.blocks.pot.StewPotBlockEntity;
import com.teammoeg.caupona.compat.top.TOPRegister;
import mcjty.theoneprobe.api.IProbeHitData;
import mcjty.theoneprobe.api.IProbeInfo;
import mcjty.theoneprobe.api.IProbeInfoProvider;
import mcjty.theoneprobe.api.ProbeMode;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.neoforged.neoforge.items.ItemStackHandler;

public class PanProvider implements IProbeInfoProvider {

@Override
public void addProbeInfo(ProbeMode mode, IProbeInfo info, Player player, Level level, BlockState state, IProbeHitData hitResult) {
if(level.getBlockEntity(hitResult.getPos()) instanceof PanBlockEntity entity) {
if(player.isShiftKeyDown()) {
ItemStackHandler inventory=entity.getInv();
List<ItemStack> inputs=new ArrayList<>();
for(int i=0;i<inventory.getSlots();i++) {
if(!inventory.getStackInSlot(i).isEmpty())
inputs.add(inventory.getStackInSlot(i));
}
if(!inputs.isEmpty()) {
IProbeInfo layout=info.horizontal(info.defaultLayoutStyle().borderColor(0x88ffffff).spacing(0));
inputs.forEach(layout::item);
}
}
if(entity.rsstate) {
info.item(new ItemStack(Items.REDSTONE_TORCH));
}
info.progress(entity.process, entity.processMax);
if(entity.processMax>0) {
if(player.isShiftKeyDown()){
if(entity.preout!=null) {
info.item(entity.preout);
}
}
}

}
}


@Override
public ResourceLocation getID() {
return TOPRegister.idForBlock("pan");
}

}

0 comments on commit 56a671f

Please sign in to comment.