Skip to content

Commit e50bb66

Browse files
committedMar 24, 2025··
make Phantom#anchorPoint nullable
1 parent 28daa6c commit e50bb66

File tree

13 files changed

+52
-44
lines changed

13 files changed

+52
-44
lines changed
 

‎paper-api/src/main/java/org/bukkit/entity/Phantom.java

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
package org.bukkit.entity;
22

3-
import org.jetbrains.annotations.NotNull;
3+
import org.bukkit.Location;
44
import org.jetbrains.annotations.Nullable;
5+
import java.util.UUID;
56

67
/**
78
* Represents a phantom.
@@ -14,18 +15,17 @@ public interface Phantom extends Flying, Enemy {
1415
public int getSize();
1516

1617
/**
17-
* @param sz The new size of the phantom.
18+
* @param size The new size of the phantom.
1819
*/
19-
public void setSize(int sz);
20+
public void setSize(int size);
2021

21-
// Paper start
2222
/**
2323
* Get the UUID of the entity that caused this phantom to spawn
2424
*
2525
* @return UUID
2626
*/
2727
@Nullable
28-
public java.util.UUID getSpawningEntity();
28+
public UUID getSpawningEntity();
2929

3030
/**
3131
* Check if this phantom will burn in the sunlight
@@ -47,14 +47,13 @@ public interface Phantom extends Flying, Enemy {
4747
*
4848
* @return circling location
4949
*/
50-
@org.jetbrains.annotations.NotNull
51-
org.bukkit.Location getAnchorLocation();
50+
@Nullable
51+
Location getAnchorLocation();
5252

5353
/**
5454
* Sets the location that this phantom circles around when not attacking a player
5555
*
5656
* @param location circling location (world is ignored, will always use the entity's world)
5757
*/
58-
void setAnchorLocation(@org.jetbrains.annotations.NotNull org.bukkit.Location location);
59-
// Paper end
58+
void setAnchorLocation(@Nullable Location location);
6059
}

‎paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch

+1-1
Original file line numberDiff line numberDiff line change
@@ -1051,7 +1051,7 @@
10511051
+ }
10521052
+ // Paper end - respect global sound events gamerule
10531053
+ // Paper start - notify observers even if grow failed
1054-
+ @Deprecated // todo check if needed
1054+
+ @Deprecated
10551055
+ public void checkCapturedTreeStateForObserverNotify(final BlockPos pos, final org.bukkit.craftbukkit.block.CraftBlockState craftBlockState) {
10561056
+ // notify observers if the block state is the same and the Y level equals the original y level (for mega trees)
10571057
+ // blocks at the same Y level with the same state can be assumed to be saplings which trigger observers regardless of if the

‎paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch

+9-2
Original file line numberDiff line numberDiff line change
@@ -406,15 +406,22 @@
406406
this.onBelowWorld();
407407
}
408408
}
409-
@@ -533,14 +_,34 @@
409+
@@ -532,15 +_,41 @@
410+
}
410411

411412
public void lavaIgnite() {
413+
+ // Paper start - track lava contact
414+
+ this.lavaIgnite(this.lastLavaContact); // fallback for minecarts if defined
415+
+ }
416+
+
417+
+ public void lavaIgnite(@Nullable BlockPos pos) {
418+
+ // Paper end - track lava contact
412419
if (!this.fireImmune()) {
413420
- this.igniteForSeconds(15.0F);
414421
+ // CraftBukkit start - Fallen in lava TODO: this event spams!
415422
+ if (this instanceof net.minecraft.world.entity.LivingEntity && this.remainingFireTicks <= 0) {
416423
+ // not on fire yet
417-
+ org.bukkit.block.Block damager = (this.lastLavaContact == null) ? null : org.bukkit.craftbukkit.block.CraftBlock.at(this.level, this.lastLavaContact);
424+
+ org.bukkit.block.Block damager = pos == null ? null : org.bukkit.craftbukkit.block.CraftBlock.at(this.level, pos);
418425
+ org.bukkit.entity.Entity damagee = this.getBukkitEntity();
419426
+ org.bukkit.event.entity.EntityCombustEvent combustEvent = new org.bukkit.event.entity.EntityCombustByBlockEvent(damager, damagee, 15.0F);
420427
+

‎paper-server/patches/sources/net/minecraft/world/entity/InsideBlockEffectType.java.patch

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
--- a/net/minecraft/world/entity/InsideBlockEffectType.java
22
+++ b/net/minecraft/world/entity/InsideBlockEffectType.java
3-
@@ -6,7 +_,7 @@
3+
@@ -6,21 +_,34 @@
44
public enum InsideBlockEffectType {
55
FREEZE(entity -> {
66
entity.setIsInPowderSnow(true);
@@ -9,8 +9,9 @@
99
entity.setTicksFrozen(Math.min(entity.getTicksRequiredToFreeze(), entity.getTicksFrozen() + 1));
1010
}
1111
}),
12-
@@ -14,13 +_,26 @@
13-
LAVA_IGNITE(Entity::lavaIgnite),
12+
FIRE_IGNITE(BaseFireBlock::fireIgnite),
13+
- LAVA_IGNITE(Entity::lavaIgnite),
14+
+ LAVA_IGNITE((entity, pos) -> entity.lavaIgnite(pos)), // Paper - track lava contact
1415
EXTINGUISH(Entity::clearFire);
1516

1617
- private final Consumer<Entity> effect;

‎paper-server/patches/sources/net/minecraft/world/level/block/LavaCauldronBlock.java.patch

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity, InsideBlockEffectApplier effectApplier) {
77
+ if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, pos)).callEvent()) { return; } // Paper - Add EntityInsideBlockEvent
88
if (this.isEntityInsideContent(state, pos, entity)) {
9-
entity.lavaIgnite();
9+
- entity.lavaIgnite();
1010
- entity.lavaHurt();
11+
+ entity.lavaIgnite(pos); // Paper - track lava contact
1112
+ entity.lavaHurt(pos); // Paper - track lava contact
1213
}
1314
}

‎paper-server/patches/sources/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java.patch

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@
152152
this.dirtyDecorations = false;
153153
- collection = MapItemSavedData.this.decorations.values();
154154
+ // CraftBukkit start
155-
+ java.util.Collection<MapDecoration> icons = new java.util.ArrayList<MapDecoration>();
155+
+ Collection<MapDecoration> icons = new java.util.ArrayList<>();
156156
+ if (vanillaMaps) this.addSeenPlayers(icons); // Paper
157157
+
158158
+ for (org.bukkit.map.MapCursor cursor : render.cursors) {

‎paper-server/src/main/java/org/bukkit/craftbukkit/CraftRaid.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@
1717
public final class CraftRaid implements Raid {
1818

1919
private final net.minecraft.world.entity.raid.Raid handle;
20+
private final Level level;
2021

21-
public CraftRaid(net.minecraft.world.entity.raid.Raid handle) {
22+
public CraftRaid(net.minecraft.world.entity.raid.Raid handle, Level level) {
2223
this.handle = handle;
24+
this.level = level;
2325
}
2426

2527
@Override
@@ -47,8 +49,7 @@ public void setBadOmenLevel(int badOmenLevel) {
4749
@Override
4850
public Location getLocation() {
4951
BlockPos pos = this.handle.getCenter();
50-
Level world = this.handle.getLevel();
51-
return CraftLocation.toBukkit(pos, world.getWorld());
52+
return CraftLocation.toBukkit(pos, this.level.getWorld());
5253
}
5354

5455
@Override

‎paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -1953,11 +1953,11 @@ public CraftMapView getMap(int id) {
19531953
public CraftMapView createMap(World world) {
19541954
Preconditions.checkArgument(world != null, "World cannot be null");
19551955

1956-
net.minecraft.world.level.Level minecraftWorld = ((CraftWorld) world).getHandle();
1956+
ServerLevel level = ((CraftWorld) world).getHandle();
19571957
// creates a new map at world spawn with the scale of 3, without tracking position and unlimited tracking
1958-
BlockPos spawn = minecraftWorld.getLevelData().getSpawnPos();
1959-
MapId newId = MapItem.createNewSavedData(minecraftWorld, spawn.getX(), spawn.getZ(), 3, false, false, minecraftWorld.dimension());
1960-
return minecraftWorld.getMapData(newId).mapView;
1958+
BlockPos spawn = level.getLevelData().getSpawnPos();
1959+
MapId newId = MapItem.createNewSavedData(level, spawn.getX(), spawn.getZ(), 3, false, false, level.dimension());
1960+
return level.getMapData(newId).mapView;
19611961
}
19621962

19631963
@Override

‎paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -2325,21 +2325,21 @@ public Raid locateNearestRaid(Location location, int radius) {
23252325

23262326
Raids persistentRaid = this.world.getRaids();
23272327
net.minecraft.world.entity.raid.Raid raid = persistentRaid.getNearbyRaid(CraftLocation.toBlockPosition(location), radius * radius);
2328-
return (raid == null) ? null : new CraftRaid(raid);
2328+
return (raid == null) ? null : new CraftRaid(raid, this.world);
23292329
}
23302330

23312331
// Paper start - more Raid API
23322332
@Override
23332333
public @Nullable Raid getRaid(final int id) {
23342334
final net.minecraft.world.entity.raid.@Nullable Raid nmsRaid = this.world.getRaids().raidMap.get(id);
2335-
return nmsRaid != null ? new CraftRaid(nmsRaid) : null;
2335+
return nmsRaid != null ? new CraftRaid(nmsRaid, this.world) : null;
23362336
}
23372337
// Paper end - more Raid API
23382338

23392339
@Override
23402340
public List<Raid> getRaids() {
23412341
Raids persistentRaid = this.world.getRaids();
2342-
return persistentRaid.raidMap.values().stream().map(CraftRaid::new).collect(Collectors.toList());
2342+
return persistentRaid.raidMap.values().stream().map(raid -> new CraftRaid(raid, this.world)).collect(Collectors.toList());
23432343
}
23442344

23452345
@Override

‎paper-server/src/main/java/org/bukkit/craftbukkit/block/CapturedBlockState.java

+1-5
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ private CapturedBlockState(CapturedBlockState state, Location location) {
3030
public boolean update(boolean force, boolean applyPhysics) {
3131
boolean result = super.update(force, applyPhysics);
3232

33-
// Probably no longer needed with the extra #updatedTree method,
34-
// but leave if here for now in case a plugin for whatever reason relies on this.
3533
if (result) {
3634
this.addBees();
3735
}
@@ -43,16 +41,14 @@ public boolean update(boolean force, boolean applyPhysics) {
4341
public boolean place(int flags) {
4442
boolean result = super.place(flags);
4543

46-
// Probably no longer needed with the extra #updatedTree method,
47-
// but leave if here for now in case a plugin for whatever reason relies on this.
4844
if (result) {
4945
this.addBees();
5046
}
5147

5248
return result;
5349
}
5450

55-
private void addBees() { // todo check if needed
51+
private void addBees() {
5652
// SPIGOT-5537: Horrible hack to manually add bees given Level#captureTreeGeneration does not support block entities
5753
if (this.treeBlock && this.getType() == Material.BEE_NEST) {
5854
WorldGenLevel worldGenLevel = this.world.getHandle();

‎paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
package org.bukkit.craftbukkit.entity;
22

3+
import net.minecraft.Optionull;
4+
import org.bukkit.Location;
35
import org.bukkit.craftbukkit.CraftServer;
46
import org.bukkit.craftbukkit.util.CraftLocation;
57
import org.bukkit.entity.Phantom;
8+
import java.util.UUID;
69

710
public class CraftPhantom extends CraftFlying implements Phantom, CraftEnemy {
811

@@ -21,8 +24,8 @@ public int getSize() {
2124
}
2225

2326
@Override
24-
public void setSize(int sz) {
25-
this.getHandle().setPhantomSize(sz);
27+
public void setSize(int size) {
28+
this.getHandle().setPhantomSize(size);
2629
}
2730

2831
@Override
@@ -31,7 +34,7 @@ public String toString() {
3134
}
3235

3336
@Override
34-
public java.util.UUID getSpawningEntity() {
37+
public UUID getSpawningEntity() {
3538
return this.getHandle().spawningEntity;
3639
}
3740

@@ -46,13 +49,13 @@ public void setShouldBurnInDay(boolean shouldBurnInDay) {
4649
}
4750

4851
@Override
49-
public org.bukkit.Location getAnchorLocation() {
50-
return CraftLocation.toBukkit(this.getHandle().anchorPoint, this.getHandle().level()); // todo NPE?
52+
public Location getAnchorLocation() {
53+
return Optionull.map(this.getHandle().anchorPoint, pos -> CraftLocation.toBukkit(pos, this.getHandle().level()));
5154
}
5255

5356
@Override
54-
public void setAnchorLocation(org.bukkit.Location location) {
57+
public void setAnchorLocation(Location location) {
5558
com.google.common.base.Preconditions.checkArgument(location != null, "location cannot be null");
56-
this.getHandle().anchorPoint = CraftLocation.toBlockPosition(location); // todo allow null?
59+
this.getHandle().anchorPoint = location == null ? null : CraftLocation.toBlockPosition(location);
5760
}
5861
}

‎paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftRaider.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public void setRaid(Raid raid) {
3333

3434
@Override
3535
public Raid getRaid() {
36-
return this.getHandle().getCurrentRaid() == null ? null : new CraftRaid(this.getHandle().getCurrentRaid());
36+
return this.getHandle().getCurrentRaid() == null ? null : new CraftRaid(this.getHandle().getCurrentRaid(), this.getHandle().level());
3737
}
3838

3939
@Override

‎paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -1779,18 +1779,18 @@ public static LightningStrikeEvent callLightningStrikeEvent(LightningStrike enti
17791779
}
17801780

17811781
public static boolean callRaidTriggerEvent(Level level, Raid raid, ServerPlayer player) {
1782-
RaidTriggerEvent event = new RaidTriggerEvent(new CraftRaid(raid), level.getWorld(), player.getBukkitEntity());
1782+
RaidTriggerEvent event = new RaidTriggerEvent(new CraftRaid(raid, level), level.getWorld(), player.getBukkitEntity());
17831783
Bukkit.getPluginManager().callEvent(event);
17841784
return !event.isCancelled();
17851785
}
17861786

17871787
public static void callRaidFinishEvent(Level level, Raid raid, List<Player> players) {
1788-
RaidFinishEvent event = new RaidFinishEvent(new CraftRaid(raid), level.getWorld(), players);
1788+
RaidFinishEvent event = new RaidFinishEvent(new CraftRaid(raid, level), level.getWorld(), players);
17891789
Bukkit.getPluginManager().callEvent(event);
17901790
}
17911791

17921792
public static void callRaidStopEvent(Level level, Raid raid, RaidStopEvent.Reason reason) {
1793-
RaidStopEvent event = new RaidStopEvent(new CraftRaid(raid), level.getWorld(), reason);
1793+
RaidStopEvent event = new RaidStopEvent(new CraftRaid(raid, level), level.getWorld(), reason);
17941794
Bukkit.getPluginManager().callEvent(event);
17951795
}
17961796

@@ -1800,7 +1800,7 @@ public static void callRaidSpawnWaveEvent(Level level, Raid raid, net.minecraft.
18001800
for (net.minecraft.world.entity.raid.Raider raider : raiders) {
18011801
bukkitRaiders.add((Raider) raider.getBukkitEntity());
18021802
}
1803-
RaidSpawnWaveEvent event = new RaidSpawnWaveEvent(new CraftRaid(raid), level.getWorld(), bukkitLeader, bukkitRaiders);
1803+
RaidSpawnWaveEvent event = new RaidSpawnWaveEvent(new CraftRaid(raid, level), level.getWorld(), bukkitLeader, bukkitRaiders);
18041804
event.callEvent();
18051805
}
18061806

0 commit comments

Comments
 (0)
Please sign in to comment.