drop custom items if giving and inventory is full
This commit is contained in:
@@ -19,8 +19,10 @@ function giveActionItem(playerId) {
|
|||||||
const player = world.getEntity(playerId);
|
const player = world.getEntity(playerId);
|
||||||
const container = player.getComponent(EntityComponentTypes.Inventory)?.container;
|
const container = player.getComponent(EntityComponentTypes.Inventory)?.container;
|
||||||
const itemStack = new ItemStack('construct:easy_place');
|
const itemStack = new ItemStack('construct:easy_place');
|
||||||
if (!container.contains(itemStack))
|
if (!container.contains(itemStack)) {
|
||||||
container.addItem(itemStack);
|
const remainingItemStack = container.addItem(itemStack);
|
||||||
|
player.dimension.spawnItem(remainingItemStack, player.location);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeActionItem(playerId) {
|
function removeActionItem(playerId) {
|
||||||
|
|||||||
@@ -21,8 +21,10 @@ function giveActionItem(playerId) {
|
|||||||
const player = world.getEntity(playerId);
|
const player = world.getEntity(playerId);
|
||||||
const container = player.getComponent(EntityComponentTypes.Inventory)?.container;
|
const container = player.getComponent(EntityComponentTypes.Inventory)?.container;
|
||||||
const itemStack = new ItemStack('construct:easy_place');
|
const itemStack = new ItemStack('construct:easy_place');
|
||||||
if (!container.contains(itemStack))
|
if (!container.contains(itemStack)) {
|
||||||
container.addItem(itemStack);
|
const remainingItemStack = container.addItem(itemStack);
|
||||||
|
player.dimension.spawnItem(remainingItemStack, player.location);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeActionItem(playerId) {
|
function removeActionItem(playerId) {
|
||||||
|
|||||||
@@ -17,8 +17,10 @@ function giveActionItem(playerId) {
|
|||||||
const player = world.getEntity(playerId);
|
const player = world.getEntity(playerId);
|
||||||
const container = player.getComponent(EntityComponentTypes.Inventory)?.container;
|
const container = player.getComponent(EntityComponentTypes.Inventory)?.container;
|
||||||
const itemStack = new ItemStack('construct:material_grabber');
|
const itemStack = new ItemStack('construct:material_grabber');
|
||||||
if (!container.contains(itemStack))
|
if (!container.contains(itemStack)) {
|
||||||
container.addItem(itemStack);
|
const remainingItemStack = container.addItem(itemStack);
|
||||||
|
player.dimension.spawnItem(remainingItemStack, player.location);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeActionItem(playerId) {
|
function removeActionItem(playerId) {
|
||||||
|
|||||||
Reference in New Issue
Block a user