fixed suction losing items.

This commit is contained in:
Brianna O'Keefe 2018-12-02 00:16:09 -05:00
parent 3bebfe6030
commit 54fce274b0
3 changed files with 17 additions and 17 deletions

View File

@ -82,8 +82,6 @@ public class HopHandler {
Hopper hopperBlock = hopper.getHopper(); Hopper hopperBlock = hopper.getHopper();
ItemStack[] is = hopperBlock.getInventory().getContents();
List<Material> blockedMaterials = new ArrayList<>(); List<Material> blockedMaterials = new ArrayList<>();
for (Module module : hopper.getLevel().getRegisteredModules()) { for (Module module : hopper.getLevel().getRegisteredModules()) {
@ -96,6 +94,8 @@ public class HopHandler {
blockedMaterials.addAll(materials); blockedMaterials.addAll(materials);
} }
ItemStack[] is = hopperBlock.getInventory().getContents();
if (hopper.getLinkedBlocks() == null || hopper.getLinkedBlocks().isEmpty()) continue; if (hopper.getLinkedBlocks() == null || hopper.getLinkedBlocks().isEmpty()) continue;
for (Block destBlock : hopper.getLinkedBlocks()) { for (Block destBlock : hopper.getLinkedBlocks()) {

View File

@ -39,36 +39,36 @@ public class ModuleSuction implements Module {
Collection<Entity> nearbyEntite = hopper.getLocation().getWorld().getNearbyEntities(hopper.getLocation().add(0.5, 0.5, 0.5), radius, radius, radius); Collection<Entity> nearbyEntite = hopper.getLocation().getWorld().getNearbyEntities(hopper.getLocation().add(0.5, 0.5, 0.5), radius, radius, radius);
for (Entity e : nearbyEntite) { for (Entity entity : nearbyEntite) {
if (!(e instanceof Item) || e.getTicksLived() < 10 || e.getLocation().getBlock().getType() == Material.HOPPER) { if (!(entity instanceof Item) || entity.getTicksLived() < 10 || entity.getLocation().getBlock().getType() == Material.HOPPER) {
continue; continue;
} }
ItemStack hopItem = ((Item) e).getItemStack().clone();
ItemStack hopItem = ((Item) entity).getItemStack().clone();
if (hopItem.getType().name().contains("SHULKER_BOX")) if (hopItem.getType().name().contains("SHULKER_BOX"))
continue; continue;
if (hopItem.hasItemMeta() && hopItem.getItemMeta().hasDisplayName() && if (hopItem.hasItemMeta() && hopItem.getItemMeta().hasDisplayName() &&
StringUtils.substring(hopItem.getItemMeta().getDisplayName(), 0, 3).equals("***")) { StringUtils.substring(hopItem.getItemMeta().getDisplayName(), 0, 3).equals("***")) {
continue; //Compatibility with Shop instance: https://www.spigotmc.org/resources/shop-a-simple-intuitive-shop-instance.9628/ continue; //Compatibility with Shop instance: https://www.spigotmc.org/resources/shop-a-simple-intuitive-shop-instance.9628/
} }
if (e.hasMetadata("grabbed")) if (entity.hasMetadata("grabbed") || !entity.isOnGround())
continue; continue;
if (Bukkit.getPluginManager().isPluginEnabled("WildStacker")) { if (Bukkit.getPluginManager().isPluginEnabled("WildStacker"))
hopItem.setAmount(WildStackerAPI.getItemAmount((Item)e)); hopItem.setAmount(WildStackerAPI.getItemAmount((Item)entity));
}
ItemStack item = ((Item) e).getItemStack(); ItemStack item = ((Item) entity).getItemStack();
if (!canMove(hopperBlock.getInventory(), item)) { if (!canMove(hopperBlock.getInventory(), item)) {
continue; continue;
} }
if (!e.isOnGround()) ((Item) entity).setPickupDelay(10);
continue; entity.setMetadata("grabbed", new FixedMetadataValue(EpicHoppersPlugin.getInstance(), ""));
((Item) e).setPickupDelay(10);
e.setMetadata("grabbed", new FixedMetadataValue(EpicHoppersPlugin.getInstance(), ""));
float xx = (float) (0 + (Math.random() * .3)); float xx = (float) (0 + (Math.random() * .3));
float yy = (float) (0 + (Math.random() * .3)); float yy = (float) (0 + (Math.random() * .3));
float zz = (float) (0 + (Math.random() * .3)); float zz = (float) (0 + (Math.random() * .3));
Arconix.pl().getApi().packetLibrary.getParticleManager().broadcastParticle(e.getLocation(), xx, yy, zz, 0, "FLAME", 5); Arconix.pl().getApi().packetLibrary.getParticleManager().broadcastParticle(entity.getLocation(), xx, yy, zz, 0, "FLAME", 5);
e.remove(); entity.remove();
hopperBlock.getInventory().addItem(hopItem); hopperBlock.getInventory().addItem(hopItem);
break; break;
} }

View File

@ -21,7 +21,7 @@ interface.hopper.teleport = "&7Teleport: &6%enabled%"
interface.hopper.filter = "&7Filter: &6%enabled%" interface.hopper.filter = "&7Filter: &6%enabled%"
interface.hopper.crafting = "&7AutoCrafting: &6%enabled%" interface.hopper.crafting = "&7AutoCrafting: &6%enabled%"
interface.hopper.suction = "&7Suction: &6%suction%" interface.hopper.suction = "&7Suction: &6%suction%"
interface.hopper.linkamount = "&7Link Amount: &6%amount%" interface.hopper.linkamount = "&7Link Overflow: &6%amount%"
interface.hopper.blockbreak = "&7Block Break: &6Every %ticks% ticks" interface.hopper.blockbreak = "&7Block Break: &6Every %ticks% ticks"
interface.hopper.alreadymaxed = "&7This hopper is already maxed out!" interface.hopper.alreadymaxed = "&7This hopper is already maxed out!"
interface.hopper.synclore = "|&7Left-Click then click a another|&7hopper or chest to link!||&7Right-Click to unlink." interface.hopper.synclore = "|&7Left-Click then click a another|&7hopper or chest to link!||&7Right-Click to unlink."