Re-add patch for PlayerSetSpawnEvent (#6977)
This commit is contained in:
parent
2450693f7d
commit
c9f9fd01b5
3 changed files with 38 additions and 11 deletions
|
@ -155,7 +155,15 @@
|
|||
}
|
||||
|
||||
}
|
||||
@@ -1375,6 +1398,8 @@
|
||||
@@ -1325,6 +1348,7 @@
|
||||
}
|
||||
|
||||
public void func_241153_a_(RegistryKey<World> p_241153_1_, @Nullable BlockPos p_241153_2_, boolean p_241153_3_, boolean p_241153_4_) {
|
||||
+ if (net.minecraftforge.event.ForgeEventFactory.onPlayerSpawnSet(this, p_241153_2_ == null ? World.field_234918_g_ : p_241153_1_, p_241153_2_, p_241153_3_)) return;
|
||||
if (p_241153_2_ != null) {
|
||||
boolean flag = p_241153_2_.equals(this.field_241138_cr_) && p_241153_1_.equals(this.field_241137_cq_);
|
||||
if (p_241153_4_ && !flag) {
|
||||
@@ -1375,6 +1399,8 @@
|
||||
if (itementity == null) {
|
||||
return null;
|
||||
} else {
|
||||
|
@ -164,7 +172,7 @@
|
|||
this.field_70170_p.func_217376_c(itementity);
|
||||
ItemStack itemstack = itementity.func_92059_d();
|
||||
if (p_146097_3_) {
|
||||
@@ -1388,4 +1413,13 @@
|
||||
@@ -1388,4 +1414,13 @@
|
||||
return itementity;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue