Skip to content

Commit

Permalink
feat: Add getActivatedWaystones, getNearestWaystone, isWaystoneActiva…
Browse files Browse the repository at this point in the history
…ted to API #917
  • Loading branch information
BlayTheNinth committed Oct 23, 2024
1 parent 68e09fb commit 7bee26f
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,20 @@
import net.blay09.mods.waystones.core.WarpMode;
import net.blay09.mods.waystones.core.WaystoneManager;
import net.blay09.mods.waystones.core.WaystoneTeleportContext;
import net.blay09.mods.waystones.item.AttunedShardItem;
import net.blay09.mods.waystones.item.BoundScrollItem;
import net.blay09.mods.waystones.item.ModItems;
import net.minecraft.core.BlockPos;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.properties.DoubleBlockHalf;
import org.jetbrains.annotations.Nullable;

import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
Expand Down Expand Up @@ -147,4 +146,19 @@ public void setBoundWaystone(ItemStack itemStack, @Nullable IWaystone waystone)
attunementItem.setWaystoneAttunedTo(itemStack, waystone);
}
}

@Override
public boolean isWaystoneActivated(Player player, IWaystone waystone) {
return PlayerWaystoneManager.isWaystoneActivated(player, waystone);
}

@Override
public Collection<IWaystone> getActivatedWaystones(Player player) {
return PlayerWaystoneManager.getWaystones(player);
}

@Override
public Optional<IWaystone> getNearestWaystone(Player player) {
return Optional.ofNullable(PlayerWaystoneManager.getNearestWaystone(player));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
import net.blay09.mods.waystones.core.WarpMode;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.Nullable;

import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
Expand Down Expand Up @@ -44,4 +46,10 @@ public interface InternalMethods {
Optional<IWaystone> getBoundWaystone(ItemStack itemStack);

void setBoundWaystone(ItemStack itemStack, @Nullable IWaystone waystone);

boolean isWaystoneActivated(Player player, IWaystone waystone);

Collection<IWaystone> getActivatedWaystones(Player player);

Optional<IWaystone> getNearestWaystone(Player player);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.Nullable;

import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
Expand Down Expand Up @@ -70,6 +72,18 @@ public static Optional<IWaystone> getWaystone(Level level, UUID uuid) {
return __internalMethods.getWaystone(level, uuid);
}

public static boolean isWaystoneActivated(Player player, IWaystone waystone) {
return __internalMethods.isWaystoneActivated(player, waystone);
}

public static Collection<IWaystone> getActivatedWaystones(Player player) {
return __internalMethods.getActivatedWaystones(player);
}

public static Optional<IWaystone> getNearestWaystone(Player player) {
return __internalMethods.getNearestWaystone(player);
}

public static Optional<IWaystone> placeWaystone(Level level, BlockPos pos, WaystoneStyle style) {
return __internalMethods.placeWaystone(level, pos, style);
}
Expand Down

0 comments on commit 7bee26f

Please sign in to comment.