Repository navigation
Drop Cooking sugar from plantation nodes #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
55 changes: 55 additions & 0 deletions
55
src/test/java/net/tfminecraft/dowsing/utils/CookingDropPathsTest.java
This file contains hidden or 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,55 @@ | ||
| package net.tfminecraft.dowsing.utils; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.*; | ||
|
|
||
| import java.io.InputStream; | ||
| import java.io.InputStreamReader; | ||
| import java.nio.charset.StandardCharsets; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| import java.util.Locale; | ||
| import java.util.Set; | ||
|
|
||
| import org.bukkit.configuration.file.YamlConfiguration; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| /** | ||
| * Cooking turns plain sugar into food only on a player's ground pickup. Node output that goes | ||
| * straight into a hopper never gets picked up, so nodes must drop Cooking's food path directly. | ||
| */ | ||
| class CookingDropPathsTest { | ||
| static final String SUGAR = "c.sweetener(type=sweetener_1;origin=Sugar)"; | ||
|
|
||
| @Test | ||
| void cookingFoodPathSurvivesTheAddDropEffectAndTheStoredToken() { | ||
| String[] effect = DropPaths.parseAddDropEffect("add_drop(" + SUGAR + ",40)"); | ||
| assertArrayEquals(new String[]{SUGAR, "40"}, effect); | ||
|
|
||
| String stored = DropPaths.formatStored(effect[0], Double.parseDouble(effect[1])); | ||
| assertEquals(SUGAR + "(40)", stored); | ||
| assertArrayEquals(new String[]{SUGAR, "40"}, DropPaths.parseStored(stored)); | ||
| } | ||
|
|
||
| @Test | ||
| void bundledPlantationsDropCookingSugarInsteadOfPlainSugar() throws Exception { | ||
| YamlConfiguration config = bundled("production_methods.yml"); | ||
| List<String> sugarDrops = new ArrayList<>(); | ||
| for (String key : config.getKeys(false)) { | ||
| for (String effect : config.getStringList(key + ".effects")) { | ||
| String[] drop = DropPaths.parseAddDropEffect(effect); | ||
| if (drop == null) continue; | ||
| assertNotEquals("v.sugar", drop[0].toLowerCase(Locale.ROOT), key + " still drops plain sugar"); | ||
| if (drop[0].equals(SUGAR)) sugarDrops.add(key); | ||
| } | ||
| } | ||
| assertEquals(3, sugarDrops.size(), sugarDrops.toString()); | ||
| assertEquals(Set.of("material_plantation", "spice_plantation", "sweet_spice_plantation"), Set.copyOf(sugarDrops)); | ||
| } | ||
|
|
||
| static YamlConfiguration bundled(String name) throws Exception { | ||
| try (InputStream in = CookingDropPathsTest.class.getClassLoader().getResourceAsStream(name)) { | ||
| assertNotNull(in, name); | ||
| return YamlConfiguration.loadConfiguration(new InputStreamReader(in, StandardCharsets.UTF_8)); | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.