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

56 lines
1.9 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 14:44:26 +01:00
import net.minecraft.core.BlockPos;
2021-12-02 12:31:04 +01:00
import net.minecraft.world.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceLocation;
2021-12-02 14:44:26 +01:00
import net.minecraft.world.level.Level;
2020-10-18 02:32:28 +02:00
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.util.INBTSerializable;
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 14:44:26 +01:00
void render(PipeBlockEntity tile, PoseStack matrixStack, Random random, float partialTicks, int light, int overlay);
2020-10-18 02:32:28 +02:00
2021-12-02 12:31:04 +01:00
static IPipeItem load(CompoundTag nbt) {
2020-10-18 02:32:28 +02:00
// TODO legacy compat, remove eventually
if (!nbt.contains("type"))
nbt.putString("type", PipeItem.TYPE.toString());
ResourceLocation type = new ResourceLocation(nbt.getString("type"));
2021-12-02 12:31:04 +01:00
BiFunction<ResourceLocation, CompoundTag, IPipeItem> func = TYPES.get(type);
2020-10-18 02:32:28 +02:00
return func != null ? func.apply(type, nbt) : null;
}
}