This commit is contained in:
yrsegal@gmail.com 2022-08-06 11:46:24 -04:00
parent 65b33e70c7
commit 1febaf703a
3 changed files with 20 additions and 20 deletions

View file

@ -15,8 +15,6 @@ import at.petrak.hexcasting.common.lib.HexItems;
import at.petrak.hexcasting.common.lib.HexSounds;
import at.petrak.hexcasting.xplat.IXplatAbstractions;
import com.mojang.datafixers.util.Pair;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
@ -36,6 +34,7 @@ import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
@ -114,9 +113,9 @@ public abstract class BlockEntityAbstractImpetus extends HexBlockEntity implemen
}
public void applyScryingLensOverlay(List<Pair<ItemStack, Component>> lines,
BlockState state, BlockPos pos,
LocalPlayer observer, ClientLevel world,
Direction hitFace) {
BlockState state, BlockPos pos,
Player observer, Level world,
Direction hitFace) {
if (world.getBlockEntity(pos) instanceof BlockEntityAbstractImpetus beai) {
if (beai.getMana() < 0) {
lines.add(new Pair<>(new ItemStack(HexItems.AMETHYST_DUST), ItemCreativeUnlocker.infiniteMedia(world)));
@ -540,6 +539,8 @@ public abstract class BlockEntityAbstractImpetus extends HexBlockEntity implemen
@Override
public boolean canPlaceItem(int index, ItemStack stack) {
if (stack.is(HexItems.CREATIVE_UNLOCKER))
return true;
var manamount = extractManaFromItem(stack, true);
return manamount > 0;
}

View file

@ -4,8 +4,8 @@ import at.petrak.hexcasting.xplat.IXplatAbstractions;
import com.google.common.collect.Lists;
import com.mojang.datafixers.util.Pair;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.world.level.Level;
import net.minecraft.world.entity.player.Player;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.network.chat.Component;
@ -37,11 +37,11 @@ public final class ScryingLensOverlayRegistry {
private static final List<Pair<OverlayPredicate, OverlayBuilder>> PREDICATE_LOOKUP = new Vector<>();
// implemented as a map to allow for weak dereferencing
private static final Map<LocalPlayer, Pair<BlockPos, Integer>> comparatorData = new WeakHashMap<>();
private static final Map<LocalPlayer, Pair<BlockPos, Integer>> beeData = new WeakHashMap<>();
private static final Map<Player, Pair<BlockPos, Integer>> comparatorData = new WeakHashMap<>();
private static final Map<Player, Pair<BlockPos, Integer>> beeData = new WeakHashMap<>();
public static void receiveComparatorAndBeeValue(BlockPos pos, int comparator, int bee) {
LocalPlayer player = Minecraft.getInstance().player;
Player player = Minecraft.getInstance().player;
if (player != null) {
if (pos == null || comparator == -1) {
comparatorData.remove(player);
@ -149,7 +149,7 @@ public final class ScryingLensOverlayRegistry {
* Internal use only.
*/
public static @NotNull List<Pair<ItemStack, Component>> getLines(BlockState state, BlockPos pos,
LocalPlayer observer, ClientLevel world,
Player observer, Level world,
Direction hitFace) {
List<Pair<ItemStack, Component>> lines = Lists.newArrayList();
var idLookedup = ID_LOOKUP.get(IXplatAbstractions.INSTANCE.getID(state.getBlock()));
@ -174,8 +174,8 @@ public final class ScryingLensOverlayRegistry {
@FunctionalInterface
public interface OverlayBuilder {
void addLines(List<Pair<ItemStack, Component>> lines,
BlockState state, BlockPos pos, LocalPlayer observer,
ClientLevel world,
BlockState state, BlockPos pos, Player observer,
Level world,
Direction hitFace);
}
@ -184,8 +184,8 @@ public final class ScryingLensOverlayRegistry {
*/
@FunctionalInterface
public interface OverlayPredicate {
boolean test(BlockState state, BlockPos pos, LocalPlayer observer,
ClientLevel world,
boolean test(BlockState state, BlockPos pos, Player observer,
Level world,
Direction hitFace);
}
}

View file

@ -5,8 +5,6 @@ import at.petrak.hexcasting.api.utils.NBTHelper;
import at.petrak.hexcasting.common.lib.HexBlockEntities;
import com.mojang.authlib.GameProfile;
import com.mojang.datafixers.util.Pair;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
@ -17,6 +15,7 @@ import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.Nullable;
@ -79,9 +78,9 @@ public class BlockEntityStoredPlayerImpetus extends BlockEntityAbstractImpetus {
}
public void applyScryingLensOverlay(List<Pair<ItemStack, Component>> lines,
BlockState state, BlockPos pos, LocalPlayer observer,
ClientLevel world,
Direction hitFace) {
BlockState state, BlockPos pos, Player observer,
Level world,
Direction hitFace) {
super.applyScryingLensOverlay(lines, state, pos, observer, world, hitFace);
var name = this.getPlayerName();