*screaming louder*
This commit is contained in:
parent
b7507d2a50
commit
1cabc187e9
3 changed files with 15 additions and 5 deletions
|
@ -1,7 +1,7 @@
|
|||
package at.petrak.hexcasting.common.misc;
|
||||
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
|
@ -11,8 +11,8 @@ import java.util.WeakHashMap;
|
|||
public final class PlayerPositionRecorder {
|
||||
private static final Map<Player, Vec3> LAST_POSITION_MAP = new WeakHashMap<>();
|
||||
|
||||
public static void updatePosition(LivingEntity e) {
|
||||
if (e instanceof ServerPlayer player) {
|
||||
public static void updateAllPlayers(ServerLevel world) {
|
||||
for (ServerPlayer player : world.players()) {
|
||||
LAST_POSITION_MAP.put(player, player.position());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,11 +9,13 @@ import at.petrak.hexcasting.common.command.PatternResLocArgument
|
|||
import at.petrak.hexcasting.common.entities.HexEntities
|
||||
import at.petrak.hexcasting.common.lib.*
|
||||
import at.petrak.hexcasting.common.misc.Brainsweeping
|
||||
import at.petrak.hexcasting.common.misc.PlayerPositionRecorder
|
||||
import at.petrak.hexcasting.common.recipe.HexRecipeSerializers
|
||||
import at.petrak.hexcasting.fabric.event.VillagerConversionCallback
|
||||
import at.petrak.hexcasting.fabric.network.FabricPacketHandler
|
||||
import net.fabricmc.api.ModInitializer
|
||||
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents
|
||||
import net.fabricmc.fabric.api.event.player.UseEntityCallback
|
||||
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry
|
||||
import net.minecraft.commands.synchronization.ArgumentTypes
|
||||
|
@ -46,6 +48,8 @@ object FabricHexInitializer : ModInitializer {
|
|||
UseEntityCallback.EVENT.register(Brainsweeping::tradeWithVillager)
|
||||
VillagerConversionCallback.EVENT.register(Brainsweeping::copyBrainsweepFromVillager)
|
||||
|
||||
ServerTickEvents.END_WORLD_TICK.register(PlayerPositionRecorder::updateAllPlayers)
|
||||
|
||||
CommandRegistrationCallback.EVENT.register { dp, _ -> HexCommands.register(dp) }
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ import at.petrak.hexcasting.xplat.IXplatAbstractions;
|
|||
import net.minecraft.commands.synchronization.ArgumentTypes;
|
||||
import net.minecraft.commands.synchronization.EmptyArgumentSerializer;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
|
@ -36,6 +37,7 @@ import net.minecraftforge.common.MinecraftForge;
|
|||
import net.minecraftforge.common.ToolActions;
|
||||
import net.minecraftforge.event.RegisterCommandsEvent;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingConversionEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
|
@ -147,7 +149,11 @@ public class ForgeHexInitializer {
|
|||
|
||||
evBus.addListener((LivingEvent.LivingUpdateEvent evt) -> {
|
||||
OpFlight.INSTANCE.tickDownFlight(evt.getEntityLiving());
|
||||
PlayerPositionRecorder.updatePosition(evt.getEntityLiving());
|
||||
});
|
||||
|
||||
evBus.addListener((TickEvent.WorldTickEvent evt) -> {
|
||||
if (evt.phase == TickEvent.Phase.END && evt.world instanceof ServerLevel world)
|
||||
PlayerPositionRecorder.updateAllPlayers(world);
|
||||
});
|
||||
|
||||
evBus.addListener((RegisterCommandsEvent evt) -> HexCommands.register(evt.getDispatcher()));
|
||||
|
|
Loading…
Reference in a new issue