From 1febaf703aa699b4c246852715796d49f7ecd0ef Mon Sep 17 00:00:00 2001 From: "yrsegal@gmail.com" Date: Sat, 6 Aug 2022 11:46:24 -0400 Subject: [PATCH] fix #196 --- .../circle/BlockEntityAbstractImpetus.java | 11 +++++----- .../client/ScryingLensOverlayRegistry.java | 20 +++++++++---------- .../BlockEntityStoredPlayerImpetus.java | 9 ++++----- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Common/src/main/java/at/petrak/hexcasting/api/block/circle/BlockEntityAbstractImpetus.java b/Common/src/main/java/at/petrak/hexcasting/api/block/circle/BlockEntityAbstractImpetus.java index 56015bdd..c995ad5a 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/block/circle/BlockEntityAbstractImpetus.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/block/circle/BlockEntityAbstractImpetus.java @@ -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> 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; } diff --git a/Common/src/main/java/at/petrak/hexcasting/api/client/ScryingLensOverlayRegistry.java b/Common/src/main/java/at/petrak/hexcasting/api/client/ScryingLensOverlayRegistry.java index 6ff8fd7c..88cc62df 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/client/ScryingLensOverlayRegistry.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/client/ScryingLensOverlayRegistry.java @@ -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> PREDICATE_LOOKUP = new Vector<>(); // implemented as a map to allow for weak dereferencing - private static final Map> comparatorData = new WeakHashMap<>(); - private static final Map> beeData = new WeakHashMap<>(); + private static final Map> comparatorData = new WeakHashMap<>(); + private static final Map> 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> getLines(BlockState state, BlockPos pos, - LocalPlayer observer, ClientLevel world, + Player observer, Level world, Direction hitFace) { List> 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> 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); } } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/blocks/entity/BlockEntityStoredPlayerImpetus.java b/Common/src/main/java/at/petrak/hexcasting/common/blocks/entity/BlockEntityStoredPlayerImpetus.java index 44f05a1a..82038f0b 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/blocks/entity/BlockEntityStoredPlayerImpetus.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/blocks/entity/BlockEntityStoredPlayerImpetus.java @@ -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> 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();