-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add /minebot stack command, make /minebot tunnel | craft | store | re…
…sume | respawn | clear compatible to 1.15
- Loading branch information
1 parent
b55add2
commit f4326ab
Showing
48 changed files
with
1,018 additions
and
668 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
Minebot/src/main/java/net/famzangl/minecraft/minebot/ai/command/StackBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package net.famzangl.minecraft.minebot.ai.command; | ||
|
||
import net.famzangl.minecraft.minebot.ai.strategy.AIStrategy; | ||
import net.famzangl.minecraft.minebot.ai.strategy.StackStrategy; | ||
import net.famzangl.minecraft.minebot.ai.strategy.StrategyStack; | ||
|
||
import java.util.ArrayList; | ||
|
||
/** | ||
* Schedule a stack of strategies and start using them | ||
*/ | ||
public class StackBuilder { | ||
|
||
private boolean collecting; | ||
private ArrayList<AIStrategy> collected = new ArrayList<>(); | ||
private SafeStrategyRule hardestSafeRule = SafeStrategyRule.NONE; | ||
|
||
public void startCollecting() { | ||
this.collecting = true; | ||
collected.clear(); | ||
hardestSafeRule = SafeStrategyRule.NONE; | ||
} | ||
|
||
public boolean collect(AIStrategy strategy, SafeStrategyRule rule) { | ||
if (collecting) { | ||
collected.add(strategy); | ||
if (rule.ordinal() > hardestSafeRule.ordinal()) { | ||
hardestSafeRule = rule; | ||
} | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
|
||
public AIStrategy getStrategy() { | ||
collecting = false; | ||
StrategyStack stack = new StrategyStack(); | ||
collected.forEach(stack::addStrategy); | ||
|
||
collected.clear(); // < to save memory | ||
return new StackStrategy(stack); | ||
} | ||
|
||
public void abort() { | ||
collecting = false; | ||
collected.clear(); // < to save memory | ||
} | ||
|
||
public boolean hasCollectedAnyStrategies() { | ||
return !collected.isEmpty(); | ||
} | ||
|
||
public boolean isCollecting() { | ||
return collecting; | ||
} | ||
|
||
public SafeStrategyRule getSafeRule() { | ||
return hardestSafeRule; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.