Skip to content

Commit

Permalink
13.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
RedLime committed Apr 16, 2023
1 parent baba417 commit 26f35eb
Showing 1 changed file with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package com.redlimerl.speedrunigt.mixins.timeline;

import com.google.common.collect.Sets;
import com.mojang.authlib.GameProfile;
import com.redlimerl.speedrunigt.timer.InGameTimer;
import com.redlimerl.speedrunigt.timer.InGameTimerUtils;
import com.redlimerl.speedrunigt.timer.TimerStatus;
import com.redlimerl.speedrunigt.timer.category.RunCategories;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.tag.SetTag;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.registry.RegistryKey;
Expand Down Expand Up @@ -54,8 +53,7 @@ public void onChangedDimension(ServerWorld destination, CallbackInfoReturnable<E
}

if (oldRegistryKey == World.NETHER && newRegistryKey == World.OVERWORLD) {
if (this.inventory.contains(SetTag.method_29900(Sets.newHashSet(Items.ENDER_EYE))) ||
(this.inventory.contains(SetTag.method_29900(Sets.newHashSet(Items.ENDER_PEARL))) && this.inventory.containsAny(Sets.newHashSet(Items.BLAZE_POWDER, Items.BLAZE_ROD)))) {
if (this.isEnoughTravel()) {
int portalIndex = InGameTimerUtils.isBlindTraveled(lastPortalPos);
InGameTimer.getInstance().tryInsertNewTimeline("nether_travel");
if (portalIndex == 0) {
Expand All @@ -69,4 +67,17 @@ public void onChangedDimension(ServerWorld destination, CallbackInfoReturnable<E
}
}
}

private boolean isEnoughTravel() {
boolean eye = false, pearl = false, rod = false;
for (ItemStack itemStack : this.inventory.main) {
if (itemStack != null) {
if (itemStack.getItem() == Items.ENDER_EYE) eye = true;
if (itemStack.getItem() == Items.ENDER_PEARL) pearl = true;
if (itemStack.getItem() == Items.BLAZE_POWDER || itemStack.getItem() == Items.BLAZE_ROD) rod = true;
}
}

return eye || (pearl && rod);
}
}

0 comments on commit 26f35eb

Please sign in to comment.