PrettyPipes/src/main/java/de/ellpeck/prettypipes/pipe/IPipeItem.java

53 lines
1.7 KiB
Java
Raw Normal View History

2020-10-18 02:32:28 +02:00
package de.ellpeck.prettypipes.pipe;
2021-12-02 14:44:26 +01:00
import com.mojang.blaze3d.vertex.PoseStack;
2020-10-18 02:32:28 +02:00
import de.ellpeck.prettypipes.network.NetworkEdge;
import de.ellpeck.prettypipes.network.PipeItem;
2021-12-02 16:55:04 +01:00
import net.minecraft.client.renderer.MultiBufferSource;
2021-12-02 14:44:26 +01:00
import net.minecraft.core.BlockPos;
2021-12-02 12:31:04 +01:00
import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceLocation;
2022-06-27 13:57:06 +02:00
import net.minecraft.world.item.ItemStack;
2021-12-02 14:44:26 +01:00
import net.minecraft.world.level.Level;
2024-02-03 15:17:58 +01:00
import net.neoforged.api.distmarker.Dist;
import net.neoforged.api.distmarker.OnlyIn;
import net.neoforged.neoforge.common.util.INBTSerializable;
2020-10-18 02:32:28 +02:00
import org.jgrapht.GraphPath;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import java.util.function.BiFunction;
2021-12-02 12:31:04 +01:00
public interface IPipeItem extends INBTSerializable<CompoundTag> {
2020-10-18 02:32:28 +02:00
2021-12-02 12:31:04 +01:00
Map<ResourceLocation, BiFunction<ResourceLocation, CompoundTag, IPipeItem>> TYPES = new HashMap<>(
2020-10-18 02:32:28 +02:00
Collections.singletonMap(PipeItem.TYPE, PipeItem::new));
ItemStack getContent();
void setDestination(BlockPos startInventory, BlockPos destInventory, GraphPath<BlockPos, NetworkEdge> path);
2021-12-02 14:44:26 +01:00
void updateInPipe(PipeBlockEntity currPipe);
2020-10-18 02:32:28 +02:00
2021-12-02 14:44:26 +01:00
void drop(Level world, ItemStack stack);
2020-10-18 02:32:28 +02:00
BlockPos getDestPipe();
BlockPos getCurrentPipe();
BlockPos getDestInventory();
int getItemsOnTheWay(BlockPos goalInv);
@OnlyIn(Dist.CLIENT)
2021-12-02 16:55:04 +01:00
void render(PipeBlockEntity tile, PoseStack matrixStack, Random random, float partialTicks, int light, int overlay, MultiBufferSource source);
2020-10-18 02:32:28 +02:00
2021-12-02 12:31:04 +01:00
static IPipeItem load(CompoundTag nbt) {
2021-12-02 16:55:04 +01:00
var type = new ResourceLocation(nbt.getString("type"));
2022-06-27 13:57:06 +02:00
var func = IPipeItem.TYPES.get(type);
2020-10-18 02:32:28 +02:00
return func != null ? func.apply(type, nbt) : null;
}
}