Re-add patch for PlayerSetSpawnEvent (#6977)

This commit is contained in:
Take Weiland authored and GitHub committed 2020-07-27 13:41:35 -07:00
1 parent 2450693f7d
commit c9f9fd01b5
3 files changed
+38 -11

No files matched your search

@@ -62,6 +62,7 @@ import net.minecraft.util.ActionResultType;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.NonNullList;
import net.minecraft.util.RegistryKey;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvent;
@@ -459,8 +460,9 @@ public class ForgeEventFactory
MinecraftForge.EVENT_BUS.post(new PlayerFlyableFallEvent(player, distance, multiplier));
}
public static boolean onPlayerSpawnSet(PlayerEntity player, BlockPos pos, boolean forced) {
return MinecraftForge.EVENT_BUS.post(new PlayerSetSpawnEvent(player, pos, forced));
public static boolean onPlayerSpawnSet(PlayerEntity player, RegistryKey<World> world, BlockPos pos, boolean forced)
{
return MinecraftForge.EVENT_BUS.post(new PlayerSetSpawnEvent(player, world, pos, forced));
}
public static void onPlayerClone(PlayerEntity player, PlayerEntity oldPlayer, boolean wasDeath)
@@ -19,33 +19,50 @@
package net.minecraftforge.event.entity.player;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraft.util.RegistryKey;
import net.minecraft.world.World;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.eventbus.api.Cancelable;
@net.minecraftforge.eventbus.api.Cancelable
import javax.annotation.Nullable;
/**
* This event is fired when a player's spawn point is set or reset.<br>
* The event can be canceled, which will prevent the spawn point from being changed.
*/
@Cancelable
public class PlayerSetSpawnEvent extends PlayerEvent
{
private final RegistryKey<World> spawnWorld;
private final boolean forced;
@Nullable
private final BlockPos newSpawn;
public PlayerSetSpawnEvent(PlayerEntity player, BlockPos newSpawn, boolean forced) {
public PlayerSetSpawnEvent(PlayerEntity player, RegistryKey<World> spawnWorld, @Nullable BlockPos newSpawn, boolean forced)
{
super(player);
this.spawnWorld = spawnWorld;
this.newSpawn = newSpawn;
this.forced = forced;
}
/**
* This event is called before a player's spawn point is changed.
* The event can be canceled, and no further processing will be done.
*/
public boolean isForced()
{
return forced;
}
/**
* The new spawn position, or null if the spawn position is being reset.
*/
@Nullable
public BlockPos getNewSpawn()
{
return newSpawn;
}
public RegistryKey<World> getSpawnWorld()
{
return spawnWorld;
}
}