Minor optimizations

This commit is contained in:
oitsjustjose 2023-11-30 08:59:08 -06:00
commit 04774107b1
2 changed files with 5 additions and 5 deletions

View file

@ -6,7 +6,7 @@ plugins {
group = 'com.oitsjustjose.itemgator'
version = "${mod_version}"
base { archivesName = "NaturalProgression-${game_version}-${mod_version}" }
base { archivesName = "ItemGator-${game_version}-${mod_version}" }
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
minecraft {

View file

@ -29,7 +29,7 @@ public class ItemGator {
}
@SubscribeEvent
public void onOther(TickEvent.PlayerTickEvent event) {
public void onTick(TickEvent.PlayerTickEvent event) {
if (event.player.isCreative()) return;
if (event.player.level().isClientSide()) return;
@ -42,15 +42,15 @@ public class ItemGator {
if (stack.isEmpty()) continue;
// Check to see if we should be replacing this item with a substitute
var shouldReplace = allRecipes.stream().filter(x -> x.matchesOriginal(stack) && x.appliesTo(event.player)).findFirst();
var shouldReplace = allRecipes.parallelStream().filter(x -> x.matchesOriginal(stack) && x.appliesTo(event.player)).findFirst();
if (shouldReplace.isPresent()) {
var sub = shouldReplace.get().getSubstitute(stack);
inventory.setItem(i, sub);
continue;
}
// See if this is a substitute and we should be replacing this item with its original because the player has the needed tag
var shouldRevert = allRecipes.stream().filter(x -> x.matchesSubstitute(stack) && !x.appliesTo(event.player)).findFirst();
// See if this is a substitute and if we should be replacing this item with its original because the player has the needed tag
var shouldRevert = allRecipes.parallelStream().filter(x -> x.matchesSubstitute(stack) && !x.appliesTo(event.player)).findFirst();
if (shouldRevert.isPresent()) {
var orig = shouldRevert.get().getOriginal(stack);
inventory.setItem(i, orig);