mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 03:35:51 +00:00
Cast inventory to a variable instead of calling getInventory() over and over
This commit is contained in:
parent
b16b936b81
commit
a876301d94
@ -211,14 +211,17 @@ public abstract class ProgrammableAndroid extends SlimefunItem {
|
||||
boolean allow = reason.equals(UnregisterReason.PLAYER_BREAK) && (BlockStorage.getBlockInfo(b, "owner").equals(p.getUniqueId().toString()) || p.hasPermission("slimefun.android.bypass"));
|
||||
|
||||
if (allow) {
|
||||
if (BlockStorage.getInventory(b).getItemInSlot(43) != null) {
|
||||
b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(43));
|
||||
BlockStorage.getInventory(b).replaceExistingItem(43, null);
|
||||
}
|
||||
for (int slot: getOutputSlots()) {
|
||||
if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) {
|
||||
b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot));
|
||||
BlockStorage.getInventory(b).replaceExistingItem(slot, null);
|
||||
BlockMenu inv = BlockStorage.getInventory(b);
|
||||
if (inv != null) {
|
||||
if (inv.getItemInSlot(43) != null) {
|
||||
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(43));
|
||||
inv.replaceExistingItem(43, null);
|
||||
}
|
||||
for (int slot: getOutputSlots()) {
|
||||
if (inv.getItemInSlot(slot) != null) {
|
||||
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
|
||||
inv.replaceExistingItem(slot, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
AndroidStatusHologram.remove(b);
|
||||
|
@ -140,16 +140,19 @@ public abstract class AContainer extends SlimefunItem {
|
||||
|
||||
@Override
|
||||
public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) {
|
||||
for (int slot: getInputSlots()) {
|
||||
if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) {
|
||||
b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot));
|
||||
BlockStorage.getInventory(b).replaceExistingItem(slot, null);
|
||||
BlockMenu inv = BlockStorage.getInventory(b);
|
||||
if (inv != null) {
|
||||
for (int slot: getInputSlots()) {
|
||||
if (inv.getItemInSlot(slot) != null) {
|
||||
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
|
||||
inv.replaceExistingItem(slot, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int slot: getOutputSlots()) {
|
||||
if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) {
|
||||
b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot));
|
||||
BlockStorage.getInventory(b).replaceExistingItem(slot, null);
|
||||
for (int slot: getOutputSlots()) {
|
||||
if (inv.getItemInSlot(slot) != null) {
|
||||
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
|
||||
inv.replaceExistingItem(slot, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
processing.remove(b);
|
||||
|
@ -68,10 +68,13 @@ public abstract class AFarm extends SlimefunItem {
|
||||
|
||||
@Override
|
||||
public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) {
|
||||
for (int slot: getOutputSlots()) {
|
||||
if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) {
|
||||
b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot));
|
||||
BlockStorage.getInventory(b).replaceExistingItem(slot, null);
|
||||
BlockMenu inv = BlockStorage.getInventory(b);
|
||||
if (inv != null) {
|
||||
for (int slot: getOutputSlots()) {
|
||||
if (inv.getItemInSlot(slot) != null) {
|
||||
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
|
||||
inv.replaceExistingItem(slot, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -210,10 +210,13 @@ public class AdvancedCargoOutputNode extends SlimefunItem {
|
||||
|
||||
@Override
|
||||
public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) {
|
||||
for (int slot: getInputSlots()) {
|
||||
if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) {
|
||||
b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot));
|
||||
BlockStorage.getInventory(b).replaceExistingItem(slot, null);
|
||||
BlockMenu inv = BlockStorage.getInventory(b);
|
||||
if (inv != null) {
|
||||
for (int slot: getInputSlots()) {
|
||||
if (inv.getItemInSlot(slot) != null) {
|
||||
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
|
||||
inv.replaceExistingItem(slot, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -70,10 +70,13 @@ public class AnimalGrowthAccelerator extends SlimefunItem {
|
||||
@Override
|
||||
public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) {
|
||||
me.mrCookieSlime.Slimefun.holograms.AnimalGrowthAccelerator.getArmorStand(b).remove();
|
||||
for (int slot: getInputSlots()) {
|
||||
if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) {
|
||||
b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot));
|
||||
BlockStorage.getInventory(b).replaceExistingItem(slot, null);
|
||||
BlockMenu inv = BlockStorage.getInventory(b);
|
||||
if (inv != null) {
|
||||
for (int slot: getInputSlots()) {
|
||||
if (inv.getItemInSlot(slot) != null) {
|
||||
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
|
||||
inv.replaceExistingItem(slot, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -70,10 +70,13 @@ public class AutoBreeder extends SlimefunItem {
|
||||
@Override
|
||||
public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) {
|
||||
me.mrCookieSlime.Slimefun.holograms.AutoBreeder.getArmorStand(b).remove();
|
||||
for (int slot: getInputSlots()) {
|
||||
if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) {
|
||||
b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot));
|
||||
BlockStorage.getInventory(b).replaceExistingItem(slot, null);
|
||||
BlockMenu inv = BlockStorage.getInventory(b);
|
||||
if (inv != null) {
|
||||
for (int slot: getInputSlots()) {
|
||||
if (inv.getItemInSlot(slot) != null) {
|
||||
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
|
||||
inv.replaceExistingItem(slot, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -105,10 +105,13 @@ public class CargoCraftingNode extends SlimefunItem {
|
||||
|
||||
@Override
|
||||
public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) {
|
||||
for (int slot: getInputSlots()) {
|
||||
if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) {
|
||||
b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot));
|
||||
BlockStorage.getInventory(b).replaceExistingItem(slot, null);
|
||||
BlockMenu inv = BlockStorage.getInventory(b);
|
||||
if (inv != null) {
|
||||
for (int slot: getInputSlots()) {
|
||||
if (inv.getItemInSlot(slot) != null) {
|
||||
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
|
||||
inv.replaceExistingItem(slot, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -236,10 +236,13 @@ public class CargoInputNode extends SlimefunItem {
|
||||
|
||||
@Override
|
||||
public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) {
|
||||
for (int slot: getInputSlots()) {
|
||||
if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) {
|
||||
b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot));
|
||||
BlockStorage.getInventory(b).replaceExistingItem(slot, null);
|
||||
BlockMenu inv = BlockStorage.getInventory(b);
|
||||
if (inv != null) {
|
||||
for (int slot: getInputSlots()) {
|
||||
if (inv.getItemInSlot(slot) != null) {
|
||||
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
|
||||
inv.replaceExistingItem(slot, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -80,10 +80,13 @@ public abstract class CropGrowthAccelerator extends SlimefunItem {
|
||||
|
||||
@Override
|
||||
public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) {
|
||||
for (int slot: getInputSlots()) {
|
||||
if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) {
|
||||
b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot));
|
||||
BlockStorage.getInventory(b).replaceExistingItem(slot, null);
|
||||
BlockMenu inv = BlockStorage.getInventory(b);
|
||||
if (inv != null) {
|
||||
for (int slot: getInputSlots()) {
|
||||
if (inv.getItemInSlot(slot) != null) {
|
||||
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
|
||||
inv.replaceExistingItem(slot, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -69,10 +69,13 @@ public class XPCollector extends SlimefunItem {
|
||||
@Override
|
||||
public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) {
|
||||
me.mrCookieSlime.Slimefun.holograms.XPCollector.getArmorStand(b).remove();
|
||||
for (int slot: getOutputSlots()) {
|
||||
if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) {
|
||||
b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot));
|
||||
BlockStorage.getInventory(b).replaceExistingItem(slot, null);
|
||||
BlockMenu inv = BlockStorage.getInventory(b);
|
||||
if (inv != null) {
|
||||
for (int slot: getOutputSlots()) {
|
||||
if (inv.getItemInSlot(slot) != null) {
|
||||
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
|
||||
inv.replaceExistingItem(slot, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user