/
Belyash5
/
Flu
Обзор
Документация
Войти
/
Belyash5
/
Flu
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/main/java/com/hbm/tileentity/IPersistentNBT.java
51 строка
1 KB
Bob
dead plants, usable presentation system
04 сен 2022, 21:23
04 сен 2022, 21:23
492440d
Код
Авторство
О чём код?
package com.hbm.tileentity; import java.util.ArrayList; import com.hbm.util.CompatExternal; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; public interface IPersistentNBT { public static final String NBT_PERSISTENT_KEY = "persistent"; public void writeNBT(NBTTagCompound nbt); public void readNBT(NBTTagCompound nbt); public default ArrayList<ItemStack> getDrops(Block b) { ArrayList<ItemStack> list = new ArrayList(); ItemStack stack = new ItemStack(b); NBTTagCompound data = new NBTTagCompound(); writeNBT(data); if(!data.hasNoTags()) stack.stackTagCompound = data; list.add(stack); return list; } public static ArrayList<ItemStack> getDrops(World world, int x, int y, int z, Block b) { TileEntity tile = CompatExternal.getCoreFromPos(world, x, y, z); if(tile instanceof IPersistentNBT) { return ((IPersistentNBT) tile).getDrops(b); } return new ArrayList(); } public static void restoreData(World world, int x, int y, int z, ItemStack stack) { try { if(!stack.hasTagCompound()) return; IPersistentNBT tile = (IPersistentNBT) world.getTileEntity(x, y, z); tile.readNBT(stack.stackTagCompound); } catch(Exception ex) { ex.printStackTrace(); } } }