Skip to content

Commit

Permalink
chore: 不嵌套
Browse files Browse the repository at this point in the history
  • Loading branch information
mcchampions committed Oct 1, 2024
1 parent df9fa57 commit 40e3047
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void preRegister() {
addItemHandler(new BlockTicker() {
@Override
public void tick(Block b, SlimefunItem sf, SlimefunBlockData data) {
ASpeedableContainer.this.tick(b,data);
ASpeedableContainer.this.tick(b, data);
}

@Override
Expand All @@ -56,20 +56,21 @@ protected void tick(Block b, SlimefunBlockData data) {
CraftingOperation currentOperation = getMachineProcessor().getOperation(b);

if (currentOperation != null) {
if (takeCharge(b.getLocation())) {
if (!currentOperation.isFinished()) {
getMachineProcessor().updateProgressBar(inv, 22, currentOperation);
currentOperation.addProgress(1);
} else {
inv.replaceExistingItem(22, new CustomItemStack(Material.BLACK_STAINED_GLASS_PANE, " "));

for (ItemStack output : currentOperation.getResults()) {
inv.pushItem(output.clone(), getOutputSlots());
}

getMachineProcessor().endOperation(b);
}
if (!takeCharge(b.getLocation())) {
return;
}
if (!currentOperation.isFinished()) {
getMachineProcessor().updateProgressBar(inv, 22, currentOperation);
currentOperation.addProgress(1);
return;
}
inv.replaceExistingItem(22, new CustomItemStack(Material.BLACK_STAINED_GLASS_PANE, " "));

for (ItemStack output : currentOperation.getResults()) {
inv.pushItem(output.clone(), getOutputSlots());
}

getMachineProcessor().endOperation(b);
} else {
MachineRecipe recipe = findNextRecipe(inv);
if (recipe != null) {
Expand Down
31 changes: 16 additions & 15 deletions src/main/java/me/qscbm/slimefun4/items/tools/OverclockModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,24 @@ public ItemUseHandler getItemHandler() {
Optional<SlimefunItem> sfBlock = e.getSlimefunBlock();
e.cancel();

if (sfBlock.isPresent() && blockOptional.isPresent()) {
Block block = blockOptional.get();
SlimefunBlockData blockData = Slimefun.getDatabaseManager()
.getBlockDataController().getBlockData(block.getLocation());
SlimefunItem item = sfBlock.get();
Player player = e.getPlayer();
if (item instanceof Speedable machine) {
if (!machine.speedUp(blockData)) {
player.sendMessage("超频倍率已达上限: " + machine.getSpeedLimit() + "x");
} else {
player.sendMessage("超频机器成功, 目前倍率: " + machine.getIncreasedSpeed(blockData) + "x");
e.getItem().setAmount(e.getItem().getAmount() - 1);
}
} else {
player.sendMessage("该机器无法超频");
if (sfBlock.isEmpty() || blockOptional.isEmpty()) {
return;
}
Block block = blockOptional.get();
SlimefunBlockData blockData = Slimefun.getDatabaseManager()
.getBlockDataController().getBlockData(block.getLocation());
SlimefunItem item = sfBlock.get();
Player player = e.getPlayer();
if (item instanceof Speedable machine) {
if (!machine.speedUp(blockData)) {
player.sendMessage("超频倍率已达上限: " + machine.getSpeedLimit() + "x");
return;
}
player.sendMessage("超频机器成功, 目前倍率: " + machine.getIncreasedSpeed(blockData) + "x");
e.getItem().setAmount(e.getItem().getAmount() - 1);
return;
}
player.sendMessage("该机器无法超频");
};
}
}
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/me/qscbm/slimefun4/utils/VersionUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ public class VersionUtils {
if (matchResult.groupCount() >= 3) {
try {
patchVersion = Integer.parseInt(matchResult.group(3), 10);
} catch (Exception ignored) {
}
} catch (Exception ignored) {}
}
if (matchResult.groupCount() >= 5) {
try {
Expand All @@ -39,8 +38,7 @@ public class VersionUtils {
} else {
releaseCandidateVersion = ver;
}
} catch (Exception ignored) {
}
} catch (Exception ignored) {}
}
}
MINECRAFT_VERSION = version;
Expand Down

0 comments on commit 40e3047

Please sign in to comment.