Skip to content

Commit 69dc688

Browse files
author
MrTwiggy
committed
Added a new config option for the maximum number of block breaks allowed
per update cycle. If an OreGin is about to perform a mining operation, but it's mining operation will exceed the number of block breaks allowed per cycle, it will reset it's timer and cancel the mining operation, attempting next time. Also added some more user-friendly interaction messages with Ore Gins.
1 parent e268159 commit 69dc688

14 files changed

+71
-15
lines changed
378 Bytes
Binary file not shown.
-19 Bytes
Binary file not shown.
Binary file not shown.
612 Bytes
Binary file not shown.
Binary file not shown.
111 Bytes
Binary file not shown.
Binary file not shown.

config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
general:
22
update_cycle: 5
3+
maximum_block_breaks_per_cycle: 500
34
save_cycle: 10
45
max_tiers: 7
56
oregin_upgrade_wand: YELLOW_FLOWER

plugin.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ name: OreGin
22
main: com.github.MrTwiggy.OreGin.OreGinPlugin
33
author: MrTwiggy
44
version: 0.1
5-
softdepend: [Citadel]
5+
depend: [Citadel]

src/com/github/MrTwiggy/OreGin/OreGin.java

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,16 @@ public void update()
117117
if (miningTimer >= oreGinProperties.GetMiningDelay())
118118
{
119119
miningTimer = 0;
120-
mineForward();
120+
if ((oreGinMan.getBlockBreaksDuringCycle()
121+
+ (oreGinProperties.GetShaftHeight()*oreGinProperties.GetShaftWidth())) < OreGinPlugin.MAXIMUM_BLOCK_BREAKS_PER_CYCLE)
122+
{
123+
mineForward();
124+
}
125+
else
126+
{
127+
OreGinPlugin.sendConsoleMessage("Maximum block breaks have been reached! "
128+
+ oreGinMan.getBlockBreaksDuringCycle() + " out of " + OreGinPlugin.MAXIMUM_BLOCK_BREAKS_PER_CYCLE);
129+
}
121130
}
122131
}
123132
else //OreGin is mining but doesn't have enough fuel
@@ -283,6 +292,7 @@ public void mineForward()
283292
if (mineBlock(startingPos.getBlock().getLocation().add(blockOffset(x,y,z)).getBlock().getRelative(facing, miningDistance + 1)))
284293
{
285294
blockBreaks++;
295+
oreGinMan.incrementBlockBreaksDuringCycle();
286296
}
287297
}
288298
}
@@ -312,9 +322,8 @@ public void mineForward()
312322
public boolean mineBlock(Block block)
313323
{
314324
Material blockType = block.getType();
315-
Location possibleLight = block.getRelative(BlockFace.UP).getLocation();
316325

317-
if ( oreGinMan.OreGinExistsAt(block.getLocation()) || oreGinMan.OreGinLightExistsAt(possibleLight))
326+
if ( oreGinMan.OreGinExistsAt(block.getLocation()) || oreGinMan.OreGinLightExistsAt(block.getLocation()))
318327
{
319328
return false;
320329
}
@@ -462,16 +471,24 @@ public String togglePower()
462471
{
463472
if (!mining)
464473
{
465-
if (fuelAvailable())
474+
if (!broken)
466475
{
467-
powerOnOreGin();
468-
return ChatColor.GREEN + "OreGin activated!";
476+
if (fuelAvailable())
477+
{
478+
powerOnOreGin();
479+
return ChatColor.GREEN + "OreGin activated!";
480+
}
481+
else
482+
{
483+
OreGinSoundCollection.ErrorSound().playSound(oreGinLocation);
484+
return ChatColor.RED + "Missing fuel! " + requiredAvailableMaterials(oreGinProperties.GetFuelAmount(),
485+
oreGinProperties.GetFuelMaterial());
486+
}
469487
}
470488
else
471489
{
472490
OreGinSoundCollection.ErrorSound().playSound(oreGinLocation);
473-
return ChatColor.RED + "Missing fuel! " + requiredAvailableMaterials(oreGinProperties.GetFuelAmount(),
474-
oreGinProperties.GetFuelMaterial());
491+
return ChatColor.RED + "OreGin is broken! You must repair it first!";
475492
}
476493
}
477494
else

0 commit comments

Comments
 (0)