forked from Mobmaker55/amidst
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Match overworld dimension instead of generating it
This commit changes the BetaMinecraftInterface to instantiate the real DimensionOverworld class, rather than generating an inheriting class with ByteBuddy. To accomplish this, I expanded the ClassTranslator to allow access to previously matched classes. This now lets us specify "empty class that inherits from DimensionBase", thus allowing us to match DimensionOverworld. I had to change ClassTranslator.translations to a List, so that iteration order would be guaranteed. I don't see why this field was a map before, other than the need to store tuples.
- Loading branch information
Showing
6 changed files
with
62 additions
and
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,27 @@ | ||
package amidst.clazz.real; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
import java.util.function.BiPredicate; | ||
import java.util.function.Predicate; | ||
import java.util.stream.Collectors; | ||
|
||
import amidst.documentation.Immutable; | ||
|
||
@Immutable | ||
public class RealClassDetector { | ||
private final Predicate<RealClass> predicate; | ||
private final BiPredicate<RealClass, Map<String, String>> predicate; | ||
|
||
public RealClassDetector(Predicate<RealClass> predicate) { | ||
public RealClassDetector(BiPredicate<RealClass, Map<String, String>> predicate) { | ||
this.predicate = predicate; | ||
} | ||
|
||
public Optional<RealClass> firstMatching(List<RealClass> realClasses) { | ||
return realClasses.stream().filter(predicate).findFirst(); | ||
public Optional<RealClass> firstMatching(List<RealClass> realClasses, Map<String, String> mappedNames) { | ||
return realClasses.stream().filter(c -> predicate.test(c, mappedNames)).findFirst(); | ||
} | ||
|
||
public List<RealClass> allMatching(List<RealClass> realClasses) { | ||
return realClasses.stream().filter(predicate).collect(Collectors.toList()); | ||
public List<RealClass> allMatching(List<RealClass> realClasses, Map<String, String> mappedNames) { | ||
return realClasses.stream().filter(c -> predicate.test(c, mappedNames)).collect(Collectors.toList()); | ||
} | ||
} |
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