1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-19 19:25:48 +00:00

Merge branch 'master' into fix/infused-hopper-picking-up-incorrect-items

This commit is contained in:
Daniel Walsh 2021-01-16 10:33:16 +00:00 committed by GitHub
commit 55d2f82dcd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 3 deletions

View File

@ -38,6 +38,8 @@
* Fixed a threading issue related to BlockStates and persistent data * Fixed a threading issue related to BlockStates and persistent data
* Fixed an error when the server was shutting down * Fixed an error when the server was shutting down
* Fixed #2721 * Fixed #2721
* Fixed #2662
* Fixed #2728
* Fixed Infused Hopper picking up items with a max pickup delay * Fixed Infused Hopper picking up items with a max pickup delay
## Release Candidate 19 (11 Jan 2021) ## Release Candidate 19 (11 Jan 2021)

View File

@ -349,7 +349,7 @@
<dependency> <dependency>
<groupId>com.github.TheBusyBiscuit</groupId> <groupId>com.github.TheBusyBiscuit</groupId>
<artifactId>CS-CoreLib2</artifactId> <artifactId>CS-CoreLib2</artifactId>
<version>0.29.2</version> <version>0.29.3</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -16,6 +16,7 @@ import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.cscorelib2.inventory.InvUtils;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper; import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper;
@ -310,7 +311,15 @@ final class CargoUtils {
} }
@Nullable @Nullable
private static ItemStack insertIntoVanillaInventory(ItemStack stack, Inventory inv) { private static ItemStack insertIntoVanillaInventory(@Nonnull ItemStack stack, @Nonnull Inventory inv) {
/*
* If the Inventory does not accept this Item Type, bounce the item back.
* Example: Shulker boxes within shulker boxes (fixes #2662)
*/
if (!InvUtils.isItemAllowed(stack.getType(), inv.getType())) {
return stack;
}
ItemStack[] contents = inv.getContents(); ItemStack[] contents = inv.getContents();
int[] range = getInputSlotRange(inv, stack); int[] range = getInputSlotRange(inv, stack);
int minSlot = range[0]; int minSlot = range[0];

View File

@ -1,5 +1,7 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.magical; package io.github.thebusybiscuit.slimefun4.implementation.items.magical;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -22,6 +24,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
*/ */
public class KnowledgeFlask extends SimpleSlimefunItem<ItemUseHandler> { public class KnowledgeFlask extends SimpleSlimefunItem<ItemUseHandler> {
@ParametersAreNonnullByDefault
public KnowledgeFlask(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) { public KnowledgeFlask(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) {
super(category, item, recipeType, recipe, recipeOutput); super(category, item, recipeType, recipe, recipeOutput);
} }
@ -33,7 +36,13 @@ public class KnowledgeFlask extends SimpleSlimefunItem<ItemUseHandler> {
if (p.getLevel() >= 1 && (!e.getClickedBlock().isPresent() || !(e.getClickedBlock().get().getType().isInteractable()))) { if (p.getLevel() >= 1 && (!e.getClickedBlock().isPresent() || !(e.getClickedBlock().get().getType().isInteractable()))) {
p.setLevel(p.getLevel() - 1); p.setLevel(p.getLevel() - 1);
p.getInventory().addItem(SlimefunItems.FILLED_FLASK_OF_KNOWLEDGE.clone());
ItemStack item = SlimefunItems.FILLED_FLASK_OF_KNOWLEDGE.clone();
if (!p.getInventory().addItem(item).isEmpty()) {
// The Item could not be added, let's drop it to the ground (fixes #2728)
p.getWorld().dropItemNaturally(p.getLocation(), item);
}
p.playSound(p.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1F, 0.5F); p.playSound(p.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1F, 0.5F);