From 682dd1f2da53948082ca883105d665cb86d34069 Mon Sep 17 00:00:00 2001 From: Qther Date: Thu, 2 Jan 2025 05:06:33 +0800 Subject: [PATCH] feat: make adjustable spell turrets use placer uuid from BasicSpellTurretTile (#1564) --- .../arsnouveau/common/block/tile/BasicSpellTurretTile.java | 2 +- .../arsnouveau/common/block/tile/RotatingTurretTile.java | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/hollingsworth/arsnouveau/common/block/tile/BasicSpellTurretTile.java b/src/main/java/com/hollingsworth/arsnouveau/common/block/tile/BasicSpellTurretTile.java index b452a5892..d893bb050 100644 --- a/src/main/java/com/hollingsworth/arsnouveau/common/block/tile/BasicSpellTurretTile.java +++ b/src/main/java/com/hollingsworth/arsnouveau/common/block/tile/BasicSpellTurretTile.java @@ -41,7 +41,7 @@ public class BasicSpellTurretTile extends ModdedTile implements ITooltipProvider boolean playRecoil; protected SpellCaster spellCaster = new SpellCaster(0, null, false, null, 1); - private @Nullable UUID uuid = null; + @Nullable UUID uuid = null; public BasicSpellTurretTile(BlockEntityType p_i48289_1_, BlockPos pos, BlockState state) { super(p_i48289_1_, pos, state); diff --git a/src/main/java/com/hollingsworth/arsnouveau/common/block/tile/RotatingTurretTile.java b/src/main/java/com/hollingsworth/arsnouveau/common/block/tile/RotatingTurretTile.java index efdcba87a..2ad969001 100644 --- a/src/main/java/com/hollingsworth/arsnouveau/common/block/tile/RotatingTurretTile.java +++ b/src/main/java/com/hollingsworth/arsnouveau/common/block/tile/RotatingTurretTile.java @@ -12,6 +12,7 @@ import com.hollingsworth.arsnouveau.common.network.PacketOneShotAnimation; import com.hollingsworth.arsnouveau.common.util.PortUtil; import com.hollingsworth.arsnouveau.setup.registry.BlockRegistry; +import com.mojang.authlib.GameProfile; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.HolderLookup; @@ -27,6 +28,7 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.Vec3; import net.neoforged.neoforge.common.util.FakePlayer; +import net.neoforged.neoforge.common.util.FakePlayerFactory; import org.jetbrains.annotations.Nullable; import static net.minecraft.core.Direction.*; @@ -156,7 +158,9 @@ public void shootSpell() { return; Networking.sendToNearbyClient(level, pos, new PacketOneShotAnimation(pos)); Position iposition = RotatingSpellTurret.getDispensePosition(pos, this); - FakePlayer fakePlayer = ANFakePlayer.getPlayer(level); + FakePlayer fakePlayer = uuid != null + ? FakePlayerFactory.get(level, new GameProfile(uuid, "")) + : ANFakePlayer.getPlayer(level); fakePlayer.setPos(pos.getX(), pos.getY(), pos.getZ()); EntitySpellResolver resolver = new EntitySpellResolver(new SpellContext(level, spellCaster.getSpell(), fakePlayer, new TileCaster(this, SpellContext.CasterType.TURRET))); if (resolver.castType != null && RotatingSpellTurret.ROT_TURRET_BEHAVIOR_MAP.containsKey(resolver.castType)) {