mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 03:35:51 +00:00
Some fixing
This commit is contained in:
parent
b9420da407
commit
5bf0b5ee74
@ -178,20 +178,18 @@ public abstract class MultiBlockMachine extends SlimefunItem implements NotPlace
|
|||||||
* A crafted {@link ItemStack} from {@link MultiBlockMachine}
|
* A crafted {@link ItemStack} from {@link MultiBlockMachine}
|
||||||
* @param block
|
* @param block
|
||||||
* Main {@link Block} of our {@link Container} from {@link MultiBlockMachine}
|
* Main {@link Block} of our {@link Container} from {@link MultiBlockMachine}
|
||||||
|
* @param blockInv
|
||||||
|
* The {@link Inventory} of our {@link Container}
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
protected void handleCraftedItem(ItemStack outputItem, Block block) {
|
protected void handleCraftedItem(ItemStack outputItem, Block block, Inventory blockInv) {
|
||||||
BlockState state = PaperLib.getBlockState(block, false).getState();
|
Inventory outputInv = findOutputInventory(outputItem, block, blockInv);
|
||||||
Validate.isTrue(state instanceof Container);
|
|
||||||
Container container = (Container) state;
|
|
||||||
Inventory containerInv = container.getInventory();
|
|
||||||
Inventory outputInv = findOutputInventory(outputItem, block, containerInv);
|
|
||||||
|
|
||||||
if (outputInv != null) {
|
if (outputInv != null) {
|
||||||
outputInv.addItem(outputItem);
|
outputInv.addItem(outputItem);
|
||||||
} else if (InvUtils.fits(containerInv, outputItem)) {
|
} else if (InvUtils.fits(blockInv, outputItem)) {
|
||||||
containerInv.addItem(outputItem);
|
blockInv.addItem(outputItem);
|
||||||
} else {
|
} else {
|
||||||
// fallback
|
// fallback
|
||||||
SlimefunUtils.spawnItem(block.getLocation(), outputItem, ItemSpawnReason.MULTIBLOCK_MACHINE_OVERFLOW, true);
|
SlimefunUtils.spawnItem(block.getLocation(), outputItem, ItemSpawnReason.MULTIBLOCK_MACHINE_OVERFLOW, true);
|
||||||
|
@ -91,7 +91,7 @@ public class ArmorForge extends AbstractCraftingTable {
|
|||||||
p.getWorld().playSound(p.getLocation(), Sound.BLOCK_ANVIL_USE, 1F, 2F);
|
p.getWorld().playSound(p.getLocation(), Sound.BLOCK_ANVIL_USE, 1F, 2F);
|
||||||
} else {
|
} else {
|
||||||
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F);
|
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F);
|
||||||
handleCraftedItem(output, dispenser);
|
handleCraftedItem(output, dispenser, inv);
|
||||||
}
|
}
|
||||||
}, j * 20L);
|
}, j * 20L);
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ public class Compressor extends MultiBlockMachine {
|
|||||||
removing.setAmount(recipeInput.getAmount());
|
removing.setAmount(recipeInput.getAmount());
|
||||||
inv.removeItem(removing);
|
inv.removeItem(removing);
|
||||||
|
|
||||||
craft(p, output, dispBlock);
|
craft(p, output, dispBlock, inv);
|
||||||
} else {
|
} else {
|
||||||
SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true);
|
SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true);
|
||||||
}
|
}
|
||||||
@ -87,7 +87,7 @@ public class Compressor extends MultiBlockMachine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
private void craft(Player p, ItemStack output, Block dispenser) {
|
private void craft(Player p, ItemStack output, Block dispenser, Inventory dispInv) {
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
int j = i;
|
int j = i;
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ public class Compressor extends MultiBlockMachine {
|
|||||||
p.getWorld().playSound(p.getLocation(), j == 1 ? Sound.BLOCK_PISTON_CONTRACT : Sound.BLOCK_PISTON_EXTEND, 1F, j == 0 ? 1F : 2F);
|
p.getWorld().playSound(p.getLocation(), j == 1 ? Sound.BLOCK_PISTON_CONTRACT : Sound.BLOCK_PISTON_EXTEND, 1F, j == 0 ? 1F : 2F);
|
||||||
} else {
|
} else {
|
||||||
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F);
|
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F);
|
||||||
handleCraftedItem(output, dispenser);
|
handleCraftedItem(output, dispenser, dispInv);
|
||||||
}
|
}
|
||||||
}, i * 20L);
|
}, i * 20L);
|
||||||
}
|
}
|
||||||
|
@ -90,13 +90,13 @@ public class MagicWorkbench extends AbstractCraftingTable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
startAnimation(p, b, dispenser, output);
|
startAnimation(p, b, inv, dispenser, output);
|
||||||
} else {
|
} else {
|
||||||
SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true);
|
SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startAnimation(Player p, Block b, Block dispenser, ItemStack output) {
|
private void startAnimation(Player p, Block b, Inventory dispInv, Block dispenser, ItemStack output) {
|
||||||
for (int j = 0; j < 4; j++) {
|
for (int j = 0; j < 4; j++) {
|
||||||
int current = j;
|
int current = j;
|
||||||
SlimefunPlugin.runSync(() -> {
|
SlimefunPlugin.runSync(() -> {
|
||||||
@ -107,7 +107,7 @@ public class MagicWorkbench extends AbstractCraftingTable {
|
|||||||
p.getWorld().playSound(b.getLocation(), Sound.BLOCK_WOODEN_BUTTON_CLICK_ON, 1F, 1F);
|
p.getWorld().playSound(b.getLocation(), Sound.BLOCK_WOODEN_BUTTON_CLICK_ON, 1F, 1F);
|
||||||
} else {
|
} else {
|
||||||
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F);
|
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F);
|
||||||
handleCraftedItem(output, dispenser);
|
handleCraftedItem(output, dispenser, dispInv);
|
||||||
}
|
}
|
||||||
}, j * 20L);
|
}, j * 20L);
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ public class PressureChamber extends MultiBlockMachine {
|
|||||||
removing.setAmount(convert.getAmount());
|
removing.setAmount(convert.getAmount());
|
||||||
inv.removeItem(removing);
|
inv.removeItem(removing);
|
||||||
|
|
||||||
craft(p, b, output, dispBlock);
|
craft(p, b, output, inv, dispBlock);
|
||||||
} else {
|
} else {
|
||||||
SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true);
|
SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true);
|
||||||
}
|
}
|
||||||
@ -71,7 +71,7 @@ public class PressureChamber extends MultiBlockMachine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
private void craft(Player p, Block b, ItemStack output, Block dispenser) {
|
private void craft(Player p, Block b, ItemStack output, Inventory dispInv, Block dispenser) {
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
int j = i;
|
int j = i;
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ public class PressureChamber extends MultiBlockMachine {
|
|||||||
p.getWorld().playSound(b.getLocation(), Sound.ENTITY_TNT_PRIMED, 1F, 1F);
|
p.getWorld().playSound(b.getLocation(), Sound.ENTITY_TNT_PRIMED, 1F, 1F);
|
||||||
} else {
|
} else {
|
||||||
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F);
|
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F);
|
||||||
handleCraftedItem(output, dispenser);
|
handleCraftedItem(output, dispenser, dispInv);
|
||||||
}
|
}
|
||||||
}, i * 20L);
|
}, i * 20L);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user