Use a Shared Random for Entities

Reduces memory usage and provides ensures more randomness, Especially since a lot of garbage entity objects get created.
This commit is contained in:
Aikar 2016-03-22 00:33:47 -04:00
parent becb30e9e6
commit d989bc5d17
2 changed files with 196 additions and 104 deletions

View file

@ -18,7 +18,7 @@
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.FenceGateBlock;
@@ -138,9 +138,67 @@
@@ -138,9 +138,140 @@
import net.minecraft.world.scores.ScoreHolder;
import net.minecraft.world.scores.Team;
import org.slf4j.Logger;
@ -61,13 +61,86 @@
+// CraftBukkit end
public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess, ScoreHolder {
+
+ // CraftBukkit start
+ private static final int CURRENT_LEVEL = 2;
+ static boolean isLevelAtLeast(CompoundTag tag, int level) {
+ return tag.contains("Bukkit.updateLevel") && tag.getInt("Bukkit.updateLevel") >= level;
+ }
+
+ // Paper start - Share random for entities to make them more random
+ public static RandomSource SHARED_RANDOM = new RandomRandomSource();
+ private static final class RandomRandomSource extends java.util.Random implements net.minecraft.world.level.levelgen.BitRandomSource {
+ private boolean locked = false;
+
+ @Override
+ public synchronized void setSeed(long seed) {
+ if (locked) {
+ LOGGER.error("Ignoring setSeed on Entity.SHARED_RANDOM", new Throwable());
+ } else {
+ super.setSeed(seed);
+ locked = true;
+ }
+ }
+
+ @Override
+ public RandomSource fork() {
+ return new net.minecraft.world.level.levelgen.LegacyRandomSource(this.nextLong());
+ }
+
+ @Override
+ public net.minecraft.world.level.levelgen.PositionalRandomFactory forkPositional() {
+ return new net.minecraft.world.level.levelgen.LegacyRandomSource.LegacyPositionalRandomFactory(this.nextLong());
+ }
+
+ // these below are added to fix reobf issues that I don't wanna deal with right now
+ @Override
+ public int next(int bits) {
+ return super.next(bits);
+ }
+
+ @Override
+ public int nextInt(int origin, int bound) {
+ return net.minecraft.world.level.levelgen.BitRandomSource.super.nextInt(origin, bound);
+ }
+
+ @Override
+ public long nextLong() {
+ return net.minecraft.world.level.levelgen.BitRandomSource.super.nextLong();
+ }
+
+ @Override
+ public int nextInt() {
+ return net.minecraft.world.level.levelgen.BitRandomSource.super.nextInt();
+ }
+
+ @Override
+ public int nextInt(int bound) {
+ return net.minecraft.world.level.levelgen.BitRandomSource.super.nextInt(bound);
+ }
+
+ @Override
+ public boolean nextBoolean() {
+ return net.minecraft.world.level.levelgen.BitRandomSource.super.nextBoolean();
+ }
+
+ @Override
+ public float nextFloat() {
+ return net.minecraft.world.level.levelgen.BitRandomSource.super.nextFloat();
+ }
+
+ @Override
+ public double nextDouble() {
+ return net.minecraft.world.level.levelgen.BitRandomSource.super.nextDouble();
+ }
+
+ @Override
+ public double nextGaussian() {
+ return super.nextGaussian();
+ }
+ }
+ // Paper end - Share random for entities to make them more random
+
+ private CraftEntity bukkitEntity;
+
+ public CraftEntity getBukkitEntity() {
@ -76,7 +149,7 @@
+ }
+ return this.bukkitEntity;
+ }
+
+ // CraftBukkit - SPIGOT-6907: re-implement LivingEntity#setMaximumAir()
+ public int getDefaultMaxAirSupply() {
+ return Entity.TOTAL_AIR_SUPPLY;
@ -86,7 +159,7 @@
private static final Logger LOGGER = LogUtils.getLogger();
public static final String ID_TAG = "id";
public static final String PASSENGERS_TAG = "Passengers";
@@ -224,7 +282,7 @@
@@ -224,7 +355,7 @@
private static final EntityDataAccessor<Boolean> DATA_CUSTOM_NAME_VISIBLE = SynchedEntityData.defineId(Entity.class, EntityDataSerializers.BOOLEAN);
private static final EntityDataAccessor<Boolean> DATA_SILENT = SynchedEntityData.defineId(Entity.class, EntityDataSerializers.BOOLEAN);
private static final EntityDataAccessor<Boolean> DATA_NO_GRAVITY = SynchedEntityData.defineId(Entity.class, EntityDataSerializers.BOOLEAN);
@ -95,7 +168,7 @@
private static final EntityDataAccessor<Integer> DATA_TICKS_FROZEN = SynchedEntityData.defineId(Entity.class, EntityDataSerializers.INT);
private EntityInLevelCallback levelCallback;
private final VecDeltaCodec packetPositionCodec;
@@ -253,7 +311,62 @@
@@ -253,7 +384,62 @@
private final List<Entity.Movement> movementThisTick;
private final Set<BlockState> blocksInside;
private final LongSet visitedBlocks;
@ -130,7 +203,7 @@
+ this.origin = location.toVector();
+ this.originWorld = location.getWorld().getUID();
+ }
+
+ @javax.annotation.Nullable
+ public org.bukkit.util.Vector getOriginVector() {
+ return this.origin != null ? this.origin.clone() : null;
@ -144,7 +217,7 @@
+ public float getBukkitYaw() {
+ return this.yRot;
+ }
+
+ public boolean isChunkLoaded() {
+ return this.level.hasChunk((int) Math.floor(this.getX()) >> 4, (int) Math.floor(this.getZ()) >> 4);
+ }
@ -158,7 +231,16 @@
public Entity(EntityType<?> type, Level world) {
this.id = Entity.ENTITY_COUNTER.incrementAndGet();
this.passengers = ImmutableList.of();
@@ -284,6 +397,13 @@
@@ -261,7 +447,7 @@
this.bb = Entity.INITIAL_AABB;
this.stuckSpeedMultiplier = Vec3.ZERO;
this.nextStep = 1.0F;
- this.random = RandomSource.create();
+ this.random = SHARED_RANDOM; // Paper - Share random for entities to make them more random
this.remainingFireTicks = -this.getFireImmuneTicks();
this.fluidHeight = new Object2DoubleArrayMap(2);
this.fluidOnEyes = new HashSet();
@@ -284,6 +470,13 @@
this.position = Vec3.ZERO;
this.blockPosition = BlockPos.ZERO;
this.chunkPosition = ChunkPos.ZERO;
@ -172,7 +254,7 @@
SynchedEntityData.Builder datawatcher_a = new SynchedEntityData.Builder(this);
datawatcher_a.define(Entity.DATA_SHARED_FLAGS_ID, (byte) 0);
@@ -292,7 +412,7 @@
@@ -292,7 +485,7 @@
datawatcher_a.define(Entity.DATA_CUSTOM_NAME, Optional.empty());
datawatcher_a.define(Entity.DATA_SILENT, false);
datawatcher_a.define(Entity.DATA_NO_GRAVITY, false);
@ -181,7 +263,7 @@
datawatcher_a.define(Entity.DATA_TICKS_FROZEN, 0);
this.defineSynchedData(datawatcher_a);
this.entityData = datawatcher_a.build();
@@ -362,20 +482,36 @@
@@ -362,19 +555,35 @@
}
public void kill(ServerLevel world) {
@ -205,8 +287,8 @@
public SynchedEntityData getEntityData() {
return this.entityData;
}
+ }
+
+ // CraftBukkit start
+ public void refreshEntityData(ServerPlayer to) {
+ List<SynchedEntityData.DataValue<?>> list = this.getEntityData().getNonDefaultValues();
@ -214,13 +296,12 @@
+ if (list != null) {
+ to.connection.send(new ClientboundSetEntityDataPacket(this.getId(), list));
+ }
+ }
}
+ // CraftBukkit end
+
public boolean equals(Object object) {
return object instanceof Entity ? ((Entity) object).id == this.id : false;
}
@@ -385,22 +521,34 @@
@@ -385,22 +594,34 @@
}
public void remove(Entity.RemovalReason reason) {
@ -260,7 +341,7 @@
return this.getPose() == pose;
}
@@ -417,6 +565,33 @@
@@ -417,6 +638,33 @@
}
public void setRot(float yaw, float pitch) {
@ -294,23 +375,24 @@
this.setYRot(yaw % 360.0F);
this.setXRot(pitch % 360.0F);
}
@@ -462,6 +637,15 @@
this.baseTick();
}
@@ -460,7 +708,16 @@
public void tick() {
this.baseTick();
+ }
+
+ // CraftBukkit start
+ public void postTick() {
+ // No clean way to break out of ticking once the entity has been copied to a new world, so instead we move the portalling later in the tick cycle
+ if (!(this instanceof ServerPlayer)) {
+ this.handlePortal();
+ }
+ }
}
+ // CraftBukkit end
+
public void baseTick() {
ProfilerFiller gameprofilerfiller = Profiler.get();
@@ -475,7 +659,7 @@
@@ -475,7 +732,7 @@
--this.boardingCooldown;
}
@ -319,7 +401,7 @@
if (this.canSpawnSprintParticle()) {
this.spawnSprintParticle();
}
@@ -514,6 +698,10 @@
@@ -514,6 +771,10 @@
if (this.isInLava()) {
this.lavaHurt();
this.fallDistance *= 0.5F;
@ -330,7 +412,7 @@
}
this.checkBelowWorld();
@@ -525,7 +713,7 @@
@@ -525,7 +786,7 @@
world = this.level();
if (world instanceof ServerLevel worldserver) {
if (this instanceof Leashable) {
@ -339,7 +421,7 @@
}
}
@@ -537,7 +725,11 @@
@@ -537,7 +798,11 @@
}
public void checkBelowWorld() {
@ -352,7 +434,7 @@
this.onBelowWorld();
}
@@ -568,15 +760,32 @@
@@ -568,15 +833,32 @@
public void lavaHurt() {
if (!this.fireImmune()) {
@ -387,7 +469,7 @@
}
}
@@ -587,7 +796,23 @@
@@ -587,7 +869,23 @@
}
public final void igniteForSeconds(float seconds) {
@ -412,7 +494,7 @@
}
public void igniteForTicks(int ticks) {
@@ -610,7 +835,7 @@
@@ -610,7 +908,7 @@
}
protected void onBelowWorld() {
@ -421,13 +503,10 @@
}
public boolean isFree(double offsetX, double offsetY, double offsetZ) {
@@ -747,8 +972,30 @@
@@ -750,6 +1048,28 @@
}
}
if (movement.y != vec3d1.y) {
block.updateEntityMovementAfterFallOn(this.level(), this);
+ }
+ }
+
+ // CraftBukkit start
+ if (this.horizontalCollision && this.getBukkitEntity() instanceof Vehicle) {
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
@ -446,13 +525,14 @@
+ if (!bl.getType().isAir()) {
+ VehicleBlockCollisionEvent event = new VehicleBlockCollisionEvent(vehicle, bl);
+ this.level.getCraftServer().getPluginManager().callEvent(event);
}
}
+ }
+ }
+ // CraftBukkit end
+
if (!this.level().isClientSide() || this.isControlledByLocalInstance()) {
Entity.MovementEmission entity_movementemission = this.getMovementEmission();
@@ -1131,8 +1378,22 @@
@@ -1131,8 +1451,22 @@
protected SoundEvent getSwimHighSpeedSplashSound() {
return SoundEvents.GENERIC_SPLASH;
@ -461,12 +541,12 @@
+ // CraftBukkit start - Add delegate methods
+ public SoundEvent getSwimSound0() {
+ return this.getSwimSound();
+ }
+
+ public SoundEvent getSwimSplashSound0() {
+ return this.getSwimSplashSound();
}
+ public SoundEvent getSwimSplashSound0() {
+ return this.getSwimSplashSound();
+ }
+
+ public SoundEvent getSwimHighSpeedSplashSound0() {
+ return this.getSwimHighSpeedSplashSound();
+ }
@ -475,7 +555,7 @@
public void recordMovementThroughBlocks(Vec3 oldPos, Vec3 newPos) {
this.movementThisTick.add(new Entity.Movement(oldPos, newPos));
}
@@ -1609,6 +1870,7 @@
@@ -1609,6 +1943,7 @@
this.yo = y;
this.zo = d4;
this.setPos(d3, y, d4);
@ -483,7 +563,7 @@
}
public void moveTo(Vec3 pos) {
@@ -1859,7 +2121,13 @@
@@ -1859,7 +2194,13 @@
public boolean isPushable() {
return false;
@ -497,7 +577,7 @@
public void awardKillScore(Entity entityKilled, DamageSource damageSource) {
if (entityKilled instanceof ServerPlayer) {
@@ -1889,16 +2157,22 @@
@@ -1889,16 +2230,22 @@
}
public boolean saveAsPassenger(CompoundTag nbt) {
@ -523,7 +603,7 @@
return true;
}
}
@@ -1909,54 +2183,98 @@
@@ -1909,54 +2256,98 @@
}
public CompoundTag saveWithoutId(CompoundTag nbt) {
@ -642,7 +722,7 @@
}
ListTag nbttaglist;
@@ -1972,10 +2290,10 @@
@@ -1972,10 +2363,10 @@
nbttaglist.add(StringTag.valueOf(s));
}
@ -655,7 +735,7 @@
if (this.isVehicle()) {
nbttaglist = new ListTag();
iterator = this.getPassengers().iterator();
@@ -1984,17 +2302,31 @@
@@ -1984,17 +2375,31 @@
Entity entity = (Entity) iterator.next();
CompoundTag nbttagcompound1 = new CompoundTag();
@ -690,11 +770,10 @@
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT");
CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Entity being saved");
@@ -2079,7 +2411,65 @@
}
@@ -2080,6 +2485,64 @@
} else {
throw new IllegalStateException("Entity has invalid position");
+ }
}
+
+ // CraftBukkit start
+ // Spigot start
@ -730,7 +809,7 @@
+ }
+
+ ((ServerPlayer) this).setLevel(bworld == null ? null : ((CraftWorld) bworld).getHandle());
}
+ }
+ this.getBukkitEntity().readBukkitValues(nbt);
+ if (nbt.contains("Bukkit.invisible")) {
+ boolean bukkitInvisible = nbt.getBoolean("Bukkit.invisible");
@ -756,7 +835,7 @@
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Loading entity NBT");
CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Entity being loaded");
@@ -2101,6 +2491,12 @@
@@ -2101,6 +2564,12 @@
return entitytypes.canSerialize() && minecraftkey != null ? minecraftkey.toString() : null;
}
@ -769,7 +848,7 @@
protected abstract void readAdditionalSaveData(CompoundTag nbt);
protected abstract void addAdditionalSaveData(CompoundTag nbt);
@@ -2153,9 +2549,22 @@
@@ -2153,9 +2622,22 @@
if (stack.isEmpty()) {
return null;
} else {
@ -792,7 +871,7 @@
world.addFreshEntity(entityitem);
return entityitem;
}
@@ -2184,6 +2593,12 @@
@@ -2184,6 +2666,12 @@
if (this.isAlive() && this instanceof Leashable leashable) {
if (leashable.getLeashHolder() == player) {
if (!this.level().isClientSide()) {
@ -805,7 +884,7 @@
if (player.hasInfiniteMaterials()) {
leashable.removeLeash();
} else {
@@ -2200,6 +2615,13 @@
@@ -2200,6 +2688,13 @@
if (itemstack.is(Items.LEAD) && leashable.canHaveALeashAttachedToIt()) {
if (!this.level().isClientSide()) {
@ -819,7 +898,7 @@
leashable.setLeashedTo(player, true);
}
@@ -2265,7 +2687,7 @@
@@ -2265,7 +2760,7 @@
}
public boolean showVehicleHealth() {
@ -828,7 +907,7 @@
}
public boolean startRiding(Entity entity, boolean force) {
@@ -2273,7 +2695,7 @@
@@ -2273,7 +2768,7 @@
return false;
} else if (!entity.couldAcceptPassenger()) {
return false;
@ -837,7 +916,7 @@
return false;
} else {
for (Entity entity1 = entity; entity1.vehicle != null; entity1 = entity1.vehicle) {
@@ -2285,11 +2707,32 @@
@@ -2285,11 +2780,32 @@
if (!force && (!this.canRide(entity) || !entity.canAddPassenger(this))) {
return false;
} else {
@ -871,7 +950,7 @@
this.vehicle = entity;
this.vehicle.addPassenger(this);
entity.getIndirectPassengersStream().filter((entity2) -> {
@@ -2318,7 +2761,7 @@
@@ -2318,7 +2834,7 @@
Entity entity = this.vehicle;
this.vehicle = null;
@ -880,7 +959,7 @@
}
}
@@ -2349,21 +2792,50 @@
@@ -2349,21 +2865,50 @@
}
}
@ -937,7 +1016,7 @@
}
protected boolean canAddPassenger(Entity passenger) {
@@ -2464,7 +2936,7 @@
@@ -2464,7 +3009,7 @@
if (teleporttransition != null) {
ServerLevel worldserver1 = teleporttransition.newLevel();
@ -946,7 +1025,7 @@
this.teleport(teleporttransition);
}
}
@@ -2547,7 +3019,7 @@
@@ -2547,7 +3092,7 @@
}
public boolean isCrouching() {
@ -955,7 +1034,7 @@
}
public boolean isSprinting() {
@@ -2563,7 +3035,7 @@
@@ -2563,7 +3108,7 @@
}
public boolean isVisuallySwimming() {
@ -964,7 +1043,7 @@
}
public boolean isVisuallyCrawling() {
@@ -2571,6 +3043,13 @@
@@ -2571,6 +3116,13 @@
}
public void setSwimming(boolean swimming) {
@ -978,7 +1057,7 @@
this.setSharedFlag(4, swimming);
}
@@ -2609,6 +3088,7 @@
@@ -2609,6 +3161,7 @@
@Nullable
public PlayerTeam getTeam() {
@ -986,7 +1065,7 @@
return this.level().getScoreboard().getPlayersTeam(this.getScoreboardName());
}
@@ -2624,8 +3104,12 @@
@@ -2624,8 +3177,12 @@
return this.getTeam() != null ? this.getTeam().isAlliedTo(team) : false;
}
@ -1000,7 +1079,7 @@
}
public boolean getSharedFlag(int index) {
@@ -2644,7 +3128,7 @@
@@ -2644,7 +3201,7 @@
}
public int getMaxAirSupply() {
@ -1009,7 +1088,7 @@
}
public int getAirSupply() {
@@ -2652,7 +3136,18 @@
@@ -2652,7 +3209,18 @@
}
public void setAirSupply(int air) {
@ -1029,7 +1108,7 @@
}
public int getTicksFrozen() {
@@ -2679,11 +3174,40 @@
@@ -2679,11 +3247,40 @@
public void thunderHit(ServerLevel world, LightningBolt lightning) {
this.setRemainingFireTicks(this.remainingFireTicks + 1);
@ -1072,7 +1151,7 @@
}
public void onAboveBubbleCol(boolean drag) {
@@ -2713,7 +3237,7 @@
@@ -2713,7 +3310,7 @@
this.resetFallDistance();
}
@ -1081,7 +1160,7 @@
return true;
}
@@ -2852,6 +3376,18 @@
@@ -2852,6 +3449,18 @@
if (world instanceof ServerLevel worldserver) {
if (!this.isRemoved()) {
@ -1100,7 +1179,7 @@
ServerLevel worldserver1 = teleportTarget.newLevel();
boolean flag = worldserver1.dimension() != worldserver.dimension();
@@ -2920,8 +3456,12 @@
@@ -2920,8 +3529,12 @@
} else {
entity.restoreFrom(this);
this.removeAfterChangingDimensions();
@ -1114,7 +1193,7 @@
Iterator iterator1 = list1.iterator();
while (iterator1.hasNext()) {
@@ -2947,7 +3487,7 @@
@@ -2947,7 +3560,7 @@
}
private void sendTeleportTransitionToRidingPlayers(TeleportTransition teleportTarget) {
@ -1123,7 +1202,7 @@
Iterator iterator = this.getIndirectPassengers().iterator();
while (iterator.hasNext()) {
@@ -2995,8 +3535,9 @@
@@ -2995,8 +3608,9 @@
}
protected void removeAfterChangingDimensions() {
@ -1134,10 +1213,12 @@
leashable.removeLeash();
}
@@ -3006,6 +3547,20 @@
return PortalShape.getRelativePosition(portalRect, portalAxis, this.position(), this.getDimensions(this.getPose()));
}
@@ -3004,7 +3618,21 @@
public Vec3 getRelativePortalPosition(Direction.Axis portalAxis, BlockUtil.FoundRectangle portalRect) {
return PortalShape.getRelativePosition(portalRect, portalAxis, this.position(), this.getDimensions(this.getPose()));
+ }
+
+ // CraftBukkit start
+ public CraftPortalEvent callPortalEvent(Entity entity, Location exit, PlayerTeleportEvent.TeleportCause cause, int searchRadius, int creationRadius) {
+ org.bukkit.entity.Entity bukkitEntity = entity.getBukkitEntity();
@ -1149,13 +1230,12 @@
+ return null;
+ }
+ return new CraftPortalEvent(event);
+ }
}
+ // CraftBukkit end
+
public boolean canUsePortal(boolean allowVehicles) {
return (allowVehicles || !this.isPassenger()) && this.isAlive();
}
@@ -3134,10 +3689,16 @@
@@ -3134,9 +3762,15 @@
return (Boolean) this.entityData.get(Entity.DATA_CUSTOM_NAME_VISIBLE);
}
@ -1166,16 +1246,15 @@
+ public final boolean teleportTo(ServerLevel world, double destX, double destY, double destZ, Set<Relative> flags, float yaw, float pitch, boolean resetCamera) {
+ return this.teleportTo(world, destX, destY, destZ, flags, yaw, pitch, resetCamera, PlayerTeleportEvent.TeleportCause.UNKNOWN);
+ }
+
+ public boolean teleportTo(ServerLevel worldserver, double d0, double d1, double d2, Set<Relative> set, float f, float f1, boolean flag, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause) {
+ float f2 = Mth.clamp(f1, -90.0F, 90.0F);
+ Entity entity = this.teleport(new TeleportTransition(worldserver, new Vec3(d0, d1, d2), Vec3.ZERO, f, f2, set, TeleportTransition.DO_NOTHING, cause));
+ // CraftBukkit end
+
return entity != null;
}
@@ -3187,7 +3748,7 @@
@@ -3187,7 +3821,7 @@
/** @deprecated */
@Deprecated
protected void fixupDimensions() {
@ -1184,7 +1263,7 @@
EntityDimensions entitysize = this.getDimensions(entitypose);
this.dimensions = entitysize;
@@ -3196,7 +3757,7 @@
@@ -3196,7 +3830,7 @@
public void refreshDimensions() {
EntityDimensions entitysize = this.dimensions;
@ -1193,7 +1272,7 @@
EntityDimensions entitysize1 = this.getDimensions(entitypose);
this.dimensions = entitysize1;
@@ -3258,10 +3819,29 @@
@@ -3258,10 +3892,29 @@
}
public final void setBoundingBox(AABB boundingBox) {
@ -1225,7 +1304,7 @@
return this.getDimensions(pose).eyeHeight();
}
@@ -3335,7 +3915,7 @@
@@ -3335,7 +3988,7 @@
}
@Nullable
@ -1234,7 +1313,7 @@
return null;
}
@@ -3435,7 +4015,7 @@
@@ -3435,7 +4088,7 @@
}
public boolean isControlledByLocalInstance() {
@ -1243,7 +1322,7 @@
if (entityliving instanceof Player entityhuman) {
return entityhuman.isLocalPlayer();
@@ -3445,7 +4025,7 @@
@@ -3445,7 +4098,7 @@
}
public boolean isControlledByClient() {
@ -1252,7 +1331,7 @@
return entityliving != null && entityliving.isControlledByClient();
}
@@ -3463,7 +4043,7 @@
@@ -3463,7 +4116,7 @@
return new Vec3((double) f1 * d2 / (double) f3, 0.0D, (double) f2 * d2 / (double) f3);
}
@ -1261,13 +1340,14 @@
return new Vec3(this.getX(), this.getBoundingBox().maxY, this.getZ());
}
@@ -3489,8 +4069,37 @@
@@ -3488,9 +4141,38 @@
public int getFireImmuneTicks() {
return 1;
}
+
+ // CraftBukkit start
+ private final CommandSource commandSource = new CommandSource() {
+
+ @Override
+ public void sendSystemMessage(Component message) {
+ }
@ -1300,19 +1380,20 @@
}
public void lookAt(EntityAnchorArgument.Anchor anchorPoint, Vec3 target) {
@@ -3551,6 +4160,11 @@
@@ -3550,7 +4232,12 @@
vec3d = vec3d.add(vec3d1);
++k1;
}
+ }
+ // CraftBukkit start - store last lava contact location
+ if (tag == FluidTags.LAVA) {
+ this.lastLavaContact = blockposition_mutableblockposition.immutable();
+ }
}
+ // CraftBukkit end
}
}
}
@@ -3613,7 +4227,7 @@
@@ -3613,7 +4300,7 @@
return new ClientboundAddEntityPacket(this, entityTrackerEntry);
}
@ -1321,7 +1402,7 @@
return this.type.getDimensions();
}
@@ -3818,8 +4432,16 @@
@@ -3818,8 +4505,16 @@
@Override
public final void setRemoved(Entity.RemovalReason reason) {
@ -1339,7 +1420,7 @@
}
if (this.removalReason.shouldDestroy()) {
@@ -3827,8 +4449,8 @@
@@ -3827,8 +4522,8 @@
}
this.getPassengers().forEach(Entity::stopRiding);
@ -1350,7 +1431,7 @@
}
public void unsetRemoved() {
@@ -3887,7 +4509,7 @@
@@ -3887,7 +4582,7 @@
}
public Vec3 getKnownMovement() {

View file

@ -0,0 +1,11 @@
--- a/net/minecraft/world/entity/animal/Squid.java
+++ b/net/minecraft/world/entity/animal/Squid.java
@@ -46,7 +46,7 @@
public Squid(EntityType<? extends Squid> type, Level world) {
super(type, world);
- this.random.setSeed((long)this.getId());
+ //this.random.setSeed((long)this.getId()); // Paper - Share random for entities to make them more random
this.tentacleSpeed = 1.0F / (this.random.nextFloat() + 1.0F) * 0.2F;
}