mc.listen("onCloseContainer", function (pl, bl,newItem) {
if (bl.name == "minecraft:ender_chest") {
var ct=pl.getEnderChest();
for(i=0;i<=26;i++)
{
newit(ct.getItem(i),pl)
}
cl(pl);
}
});
function cl(pl){
pl.getEnderChest().removeAllItems();
}
function newit(newItem,pl){
mc.spawnItem(mc.newItem(newItem.type, newItem.count), pl.pos);
};
以上为源代码,禁止商业化,仅供学习和参考,一切归全体劳动人民所有