Skip to content

Commit

Permalink
fix 1.12.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Himmelt committed Apr 22, 2020
1 parent fe760b5 commit 01eaeac
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public static void give(EntityPlayer target, ItemStack itemStack, int count) {
if (count > 0) {
it.setCount(count);
}
boolean flag = target.inventory.addItemStackToInventory(itemStack);
boolean flag = target.inventory.addItemStackToInventory(it);
if (flag) {
target.world.playSound(null, target.posX, target.posY, target.posZ, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.2F, ((target.getRNG().nextFloat() - target.getRNG().nextFloat()) * 0.7F + 1.0F) * 2.0F);
target.inventoryContainer.detectAndSendChanges();
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/org/soraworld/itemsaver/common/ItemTypeData.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,21 @@ public boolean has(String key) {
}

public ItemStack get(String key) {
return stacks.get(key);
ItemStack stack = stacks.get(key);
return stack == null ? null : stack.copy();
}

public boolean add(String key, ItemStack stack) {
if (!stacks.containsKey(key)) {
stacks.put(key, stack);
stacks.put(key, stack.copy());
markDirty();
return true;
}
return false;
}

public void set(String key, ItemStack stack) {
stacks.put(key, stack);
stacks.put(key, stack.copy());
markDirty();
}

Expand Down Expand Up @@ -104,10 +105,10 @@ public void give(EntityPlayerMP target, String name, int amount) {
if (name != null) {
ItemStack stack = stacks.get(name);
if (stack != null) {
CommonProxy.give(target, stack, amount);
CommonProxy.give(target, stack.copy(), amount);
}
} else {
stacks.values().forEach(stack -> CommonProxy.give(target, stack, -1));
stacks.values().forEach(stack -> CommonProxy.give(target, stack.copy(), -1));
}
}
}

0 comments on commit 01eaeac

Please sign in to comment.