Create a new event and add a few fields to existing events

This commit is contained in:
Aria 2023-03-05 15:53:56 -07:00
parent 957b65ebb3
commit ede19b0572
8 changed files with 61 additions and 11 deletions

View file

@ -4,6 +4,7 @@ import dev.zontreck.libzontreck.LibZontreck;
import dev.zontreck.libzontreck.memory.PlayerContainer;
import dev.zontreck.libzontreck.profiles.Profile;
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
@ -41,8 +42,9 @@ public class ForgeEventHandlers {
ServerPlayer player = (ServerPlayer)ev.getPlayer();
Profile prof = Profile.factory(player);
ServerLevel level = player.getLevel();
MinecraftForge.EVENT_BUS.post(new ProfileLoadedEvent(prof));
MinecraftForge.EVENT_BUS.post(new ProfileLoadedEvent(prof, player, level));
}
@SubscribeEvent

View file

@ -1,13 +1,19 @@
package dev.zontreck.libzontreck.events;
import dev.zontreck.libzontreck.profiles.Profile;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraftforge.eventbus.api.Event;
public class ProfileLoadedEvent extends Event
{
public Profile profile;
public ProfileLoadedEvent(Profile prof)
public ServerPlayer player;
public ServerLevel level;
public ProfileLoadedEvent(Profile prof, ServerPlayer player, ServerLevel level)
{
profile=prof;
this.player=player;
this.level=level;
}
}

View file

@ -1,5 +1,6 @@
package dev.zontreck.libzontreck.events;
import dev.zontreck.libzontreck.profiles.Profile;
import net.minecraftforge.eventbus.api.Event;
public class ProfileUnloadedEvent extends Event

View file

@ -0,0 +1,19 @@
package dev.zontreck.libzontreck.events;
import dev.zontreck.libzontreck.profiles.Profile;
import net.minecraft.server.level.ServerPlayer;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;
@Cancelable
public class ProfileUnloadingEvent extends Event
{
public Profile profile;
public ServerPlayer player;
public ProfileUnloadingEvent(Profile profile, ServerPlayer player)
{
this.profile=profile;
this.player=player;
}
}