specify inventory changes
This commit is contained in:
1 parent
a0bd6e22ac
commit
289df9d9f8
4 files changed
+21
-12
No files matched your search
@@ -27,10 +27,11 @@ public abstract class Inventory_scarpetEventMixin
|
||||
if (!PLAYER_PICKS_UP_ITEM.isNeeded() || !(player instanceof ServerPlayer))
|
||||
return playerInventory.add(-1, stack);
|
||||
int count = stack.getCount();
|
||||
ItemStack previous = stack.copy();
|
||||
boolean res = playerInventory.add(-1, stack);
|
||||
if (count != stack.getCount()) // res returns false for larger item adding to a almost full ineventory
|
||||
{
|
||||
ItemStack diffStack = stack.copyWithCount(count - stack.getCount());
|
||||
ItemStack diffStack = previous.copyWithCount(count - stack.getCount());
|
||||
PLAYER_PICKS_UP_ITEM.onItemAction((ServerPlayer) player, null, diffStack);
|
||||
}
|
||||
return res;
|
||||
|
||||
@@ -1661,7 +1661,7 @@ public class ShapeDispatcher
|
||||
public Value validate(Map<String, Value> options, MinecraftServer server, Value value)
|
||||
{
|
||||
ItemStack item = ValueConversions.getItemStackFromValue(value, true, server.registryAccess());
|
||||
return new NBTSerializableValue(item.save(server.registryAccess()));
|
||||
return new NBTSerializableValue(item.saveOptional(server.registryAccess()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -313,11 +313,16 @@ __on_player_swaps_hands(player) -> (
|
||||
// print(' Player '+player+' collides with '+entity);
|
||||
//);
|
||||
|
||||
__on_player_picks_up_item(player, item) ->
|
||||
__on_player_picks_up_item(player, item_tuple) ->
|
||||
(
|
||||
l(item, count, nbt) = item_tuple || l('None', 0, null);
|
||||
print('');
|
||||
print('__on_player_picks_up_item(player, item)');
|
||||
print(' Player '+player+' injects '+item);
|
||||
print(' - player: '+player);
|
||||
print(' - item:');
|
||||
print(' > name: '+item);
|
||||
print(' > count: '+count);
|
||||
print(' > nbt: '+nbt);
|
||||
);
|
||||
|
||||
__on_player_trades(player, entity, buy_left, buy_right, sell) ->
|
||||
|
||||
Reference in new issue
Block a user