Add EntityMoveEvent

This commit is contained in:
William Blake Galbreath 2020-02-11 21:56:48 -06:00
parent 6f6ed7acb9
commit 48c492c4d1
3 changed files with 128 additions and 103 deletions

View File

@ -555,10 +555,12 @@
if (!iworlddataserver.isInitialized()) {
try {
@@ -427,30 +717,8 @@
iworlddataserver.setInitialized(true);
}
@@ -425,32 +715,10 @@
}
iworlddataserver.setInitialized(true);
- }
-
- this.getPlayerList().addWorldborderListener(worldserver);
- if (this.worldData.getCustomBossEvents() != null) {
- this.getCustomBossEvents().load(this.worldData.getCustomBossEvents(), this.registryAccess());
@ -579,8 +581,8 @@
- worldborder.addListener(new BorderChangeListener.DelegateBorderChangeListener(worldserver1.getWorldBorder()));
- this.levels.put(resourcekey1, worldserver1);
- }
- }
-
}
- worldborder.applySettings(iworlddataserver.getWorldBorder());
}
+ // CraftBukkit end
@ -1029,7 +1031,7 @@
ObjectArrayList<GameProfile> objectarraylist = new ObjectArrayList(j);
int k = Mth.nextInt(this.random, 0, list.size() - j);
@@ -1154,24 +1611,55 @@
@@ -1154,24 +1611,56 @@
this.getPlayerList().getPlayers().forEach((entityplayer) -> {
entityplayer.connection.suspendFlushing();
});
@ -1069,6 +1071,7 @@
while (iterator.hasNext()) {
ServerLevel worldserver = (ServerLevel) iterator.next();
+ worldserver.hasPhysicsEvent = org.bukkit.event.block.BlockPhysicsEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - BlockPhysicsEvent
+ worldserver.hasEntityMoveEvent = io.papermc.paper.event.entity.EntityMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - Add EntityMoveEvent
gameprofilerfiller.push(() -> {
String s = String.valueOf(worldserver);
@ -1085,7 +1088,7 @@
gameprofilerfiller.push("tick");
@@ -1186,6 +1674,7 @@
@@ -1186,6 +1675,7 @@
gameprofilerfiller.pop();
gameprofilerfiller.pop();
@ -1093,7 +1096,7 @@
}
gameprofilerfiller.popPush("connection");
@@ -1267,6 +1756,22 @@
@@ -1267,6 +1757,22 @@
return (ServerLevel) this.levels.get(key);
}
@ -1116,7 +1119,7 @@
public Set<ResourceKey<Level>> levelKeys() {
return this.levels.keySet();
}
@@ -1296,7 +1801,7 @@
@@ -1296,7 +1802,7 @@
@DontObfuscate
public String getServerModName() {
@ -1125,7 +1128,7 @@
}
public SystemReport fillSystemReport(SystemReport details) {
@@ -1347,7 +1852,7 @@
@@ -1347,7 +1853,7 @@
@Override
public void sendSystemMessage(Component message) {
@ -1134,7 +1137,7 @@
}
public KeyPair getKeyPair() {
@@ -1385,11 +1890,14 @@
@@ -1385,11 +1891,14 @@
}
}
@ -1154,7 +1157,7 @@
}
}
@@ -1403,7 +1911,7 @@
@@ -1403,7 +1912,7 @@
while (iterator.hasNext()) {
ServerLevel worldserver = (ServerLevel) iterator.next();
@ -1163,7 +1166,7 @@
}
}
@@ -1481,10 +1989,20 @@
@@ -1481,10 +1990,20 @@
@Override
public String getMotd() {
@ -1185,7 +1188,7 @@
this.motd = motd;
}
@@ -1507,7 +2025,7 @@
@@ -1507,7 +2026,7 @@
}
public ServerConnectionListener getConnection() {
@ -1194,7 +1197,7 @@
}
public boolean isReady() {
@@ -1632,13 +2150,19 @@
@@ -1632,13 +2151,19 @@
return this.functionManager;
}
@ -1216,7 +1219,7 @@
}, this).thenCompose((immutablelist) -> {
MultiPackResourceManager resourcemanager = new MultiPackResourceManager(PackType.SERVER_DATA, immutablelist);
List<Registry.PendingTags<?>> list = TagLoader.loadTagsForExistingRegistries(resourcemanager, this.registries.compositeAccess());
@@ -1654,6 +2178,7 @@
@@ -1654,6 +2179,7 @@
}).thenAcceptAsync((minecraftserver_reloadableresources) -> {
this.resources.close();
this.resources = minecraftserver_reloadableresources;
@ -1224,7 +1227,7 @@
this.packRepository.setSelected(dataPacks);
WorldDataConfiguration worlddataconfiguration = new WorldDataConfiguration(MinecraftServer.getSelectedPacks(this.packRepository, true), this.worldData.enabledFeatures());
@@ -1665,6 +2190,8 @@
@@ -1665,6 +2191,8 @@
this.functionManager.replaceLibrary(this.resources.managers.getFunctionLibrary());
this.structureTemplateManager.onResourceManagerReload(this.resources.resourceManager);
this.fuelValues = FuelValues.vanillaBurnTimes(this.registries.compositeAccess(), this.worldData.enabledFeatures());
@ -1233,7 +1236,7 @@
}, this);
if (this.isSameThread()) {
@@ -1789,13 +2316,14 @@
@@ -1789,13 +2317,14 @@
if (this.isEnforceWhitelist()) {
PlayerList playerlist = source.getServer().getPlayerList();
UserWhiteList whitelist = playerlist.getWhiteList();
@ -1249,7 +1252,7 @@
entityplayer.connection.disconnect((Component) Component.translatable("multiplayer.disconnect.not_whitelisted"));
}
}
@@ -1952,7 +2480,7 @@
@@ -1952,7 +2481,7 @@
final List<String> list = Lists.newArrayList();
final GameRules gamerules = this.getGameRules();
@ -1258,7 +1261,7 @@
@Override
public <T extends GameRules.Value<T>> void visit(GameRules.Key<T> key, GameRules.Type<T> type) {
list.add(String.format(Locale.ROOT, "%s=%s\n", key.getId(), gamerules.getRule(key)));
@@ -2058,7 +2586,7 @@
@@ -2058,7 +2587,7 @@
try {
label51:
{
@ -1267,7 +1270,7 @@
try {
arraylist = Lists.newArrayList(NativeModuleLister.listModules());
@@ -2105,9 +2633,24 @@
@@ -2105,9 +2634,24 @@
if (bufferedwriter != null) {
bufferedwriter.close();
}
@ -1292,7 +1295,7 @@
private ProfilerFiller createProfiler() {
if (this.willStartRecordingMetrics) {
this.metricsRecorder = ActiveMetricsRecorder.createStarted(new ServerMetricsSamplersProvider(Util.timeSource, this.isDedicatedServer()), Util.timeSource, Util.ioPool(), new MetricsPersister("server"), this.onMetricsRecordingStopped, (path) -> {
@@ -2225,18 +2768,24 @@
@@ -2225,18 +2769,24 @@
}
public void logChatMessage(Component message, ChatType.Bound params, @Nullable String prefix) {
@ -1321,7 +1324,7 @@
}
public boolean logIPs() {
@@ -2377,6 +2926,32 @@
@@ -2377,6 +2927,32 @@
}
public static record ServerResourcePackInfo(UUID id, String url, String hash, boolean isRequired, @Nullable Component prompt) {

View File

@ -61,7 +61,7 @@
private int lastSpawnChunkRadius;
final EntityTickList entityTickList = new EntityTickList();
public final PersistentEntitySectionManager<Entity> entityManager;
@@ -214,54 +226,203 @@
@@ -214,54 +226,204 @@
private final boolean tickTime;
private final RandomSequences randomSequences;
@ -79,6 +79,7 @@
+ public final LevelStorageSource.LevelStorageAccess convertable;
+ public final UUID uuid;
+ public boolean hasPhysicsEvent = true; // Paper - BlockPhysicsEvent
+ public boolean hasEntityMoveEvent; // Paper - Add EntityMoveEvent
+
+ public LevelChunk getChunkIfLoaded(int x, int z) {
+ return this.chunkSource.getChunk(x, z, false);
@ -132,7 +133,7 @@
+
+ int maxBlockX = Mth.floor(axisalignedbb.maxX + 1.0E-7D) + 3;
+ int maxBlockZ = Mth.floor(axisalignedbb.maxZ + 1.0E-7D) + 3;
+
+ int minChunkX = minBlockX >> 4;
+ int minChunkZ = minBlockZ >> 4;
+
@ -218,7 +219,7 @@
+ chunkgenerator = new FlatLevelSource(cpf.settings(), worldChunkManager);
+ }
+ }
+
+ if (gen != null) {
+ chunkgenerator = new org.bukkit.craftbukkit.generator.CustomChunkGenerator(this, chunkgenerator, gen);
+ }
@ -289,7 +290,7 @@
/** @deprecated */
@Deprecated
@VisibleForTesting
@@ -305,12 +466,20 @@
@@ -305,12 +467,20 @@
long j;
if (this.sleepStatus.areEnoughSleeping(i) && this.sleepStatus.areEnoughDeepSleeping(i, this.players)) {
@ -313,7 +314,7 @@
if (this.getGameRules().getBoolean(GameRules.RULE_WEATHER_CYCLE) && this.isRaining()) {
this.resetWeatherCycle();
}
@@ -345,7 +514,7 @@
@@ -345,7 +515,7 @@
this.handlingTick = false;
gameprofilerfiller.pop();
@ -322,7 +323,7 @@
if (flag1) {
this.resetEmptyTime();
@@ -359,6 +528,7 @@
@@ -359,6 +529,7 @@
gameprofilerfiller.pop();
}
@ -330,7 +331,7 @@
this.entityTickList.forEach((entity) -> {
if (!entity.isRemoved()) {
if (!tickratemanager.isEntityFrozen(entity)) {
@@ -429,7 +599,7 @@
@@ -429,7 +600,7 @@
private void wakeUpAllPlayers() {
this.sleepStatus.removeAllSleepers();
@ -339,7 +340,7 @@
entityplayer.stopSleepInBed(false, false);
});
}
@@ -442,12 +612,12 @@
@@ -442,12 +613,12 @@
ProfilerFiller gameprofilerfiller = Profiler.get();
gameprofilerfiller.push("thunder");
@ -354,7 +355,7 @@
if (flag1) {
SkeletonHorse entityhorseskeleton = (SkeletonHorse) EntityType.SKELETON_HORSE.create(this, EntitySpawnReason.EVENT);
@@ -456,7 +626,7 @@
@@ -456,7 +627,7 @@
entityhorseskeleton.setTrap(true);
entityhorseskeleton.setAge(0);
entityhorseskeleton.setPos((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ());
@ -363,7 +364,7 @@
}
}
@@ -465,18 +635,20 @@
@@ -465,18 +636,20 @@
if (entitylightning != null) {
entitylightning.moveTo(Vec3.atBottomCenterOf(blockposition));
entitylightning.setVisualOnly(flag1);
@ -385,7 +386,7 @@
gameprofilerfiller.popPush("tickBlocks");
if (randomTickSpeed > 0) {
@@ -521,7 +693,7 @@
@@ -521,7 +694,7 @@
Biome biomebase = (Biome) this.getBiome(blockposition1).value();
if (biomebase.shouldFreeze(this, blockposition2)) {
@ -394,7 +395,7 @@
}
if (this.isRaining()) {
@@ -537,10 +709,10 @@
@@ -537,10 +710,10 @@
BlockState iblockdata1 = (BlockState) iblockdata.setValue(SnowLayerBlock.LAYERS, j + 1);
Block.pushEntitiesUp(iblockdata, iblockdata1, this, blockposition1);
@ -407,7 +408,7 @@
}
}
@@ -701,33 +873,67 @@
@@ -701,33 +874,67 @@
this.rainLevel = Mth.clamp(this.rainLevel, 0.0F, 1.0F);
}
@ -483,7 +484,7 @@
}
public void resetEmptyTime() {
@@ -754,6 +960,13 @@
@@ -754,6 +961,13 @@
}
public void tickNonPassenger(Entity entity) {
@ -497,7 +498,7 @@
entity.setOldPosAndRot();
ProfilerFiller gameprofilerfiller = Profiler.get();
@@ -763,6 +976,7 @@
@@ -763,6 +977,7 @@
});
gameprofilerfiller.incrementCounter("tickNonPassenger");
entity.tick();
@ -505,7 +506,7 @@
gameprofilerfiller.pop();
Iterator iterator = entity.getPassengers().iterator();
@@ -786,6 +1000,7 @@
@@ -786,6 +1001,7 @@
});
gameprofilerfiller.incrementCounter("tickPassenger");
passenger.rideTick();
@ -513,7 +514,7 @@
gameprofilerfiller.pop();
Iterator iterator = passenger.getPassengers().iterator();
@@ -810,6 +1025,7 @@
@@ -810,6 +1026,7 @@
ServerChunkCache chunkproviderserver = this.getChunkSource();
if (!savingDisabled) {
@ -521,7 +522,7 @@
if (progressListener != null) {
progressListener.progressStartNoAbort(Component.translatable("menu.savingLevel"));
}
@@ -827,11 +1043,19 @@
@@ -827,11 +1044,19 @@
}
}
@ -542,7 +543,7 @@
}
DimensionDataStorage worldpersistentdata = this.getChunkSource().getDataStorage();
@@ -903,18 +1127,40 @@
@@ -903,18 +1128,40 @@
@Override
public boolean addFreshEntity(Entity entity) {
@ -586,7 +587,7 @@
}
}
@@ -939,41 +1185,99 @@
@@ -939,41 +1186,99 @@
this.entityManager.addNewEntity(player);
}
@ -691,7 +692,7 @@
while (iterator.hasNext()) {
ServerPlayer entityplayer = (ServerPlayer) iterator.next();
@@ -982,6 +1286,12 @@
@@ -982,6 +1287,12 @@
double d1 = (double) pos.getY() - entityplayer.getY();
double d2 = (double) pos.getZ() - entityplayer.getZ();
@ -704,7 +705,7 @@
if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) {
entityplayer.connection.send(new ClientboundBlockDestructionPacket(entityId, pos, progress));
}
@@ -1030,7 +1340,7 @@
@@ -1030,7 +1341,7 @@
@Override
public void levelEvent(@Nullable Player player, int eventId, BlockPos pos, int data) {
@ -713,7 +714,7 @@
}
public int getLogicalHeight() {
@@ -1060,7 +1370,18 @@
@@ -1060,7 +1371,18 @@
Iterator iterator = this.navigatingMobs.iterator();
while (iterator.hasNext()) {
@ -733,7 +734,7 @@
PathNavigation navigationabstract = entityinsentient.getNavigation();
if (navigationabstract.shouldRecomputePath(pos)) {
@@ -1086,11 +1407,13 @@
@@ -1086,11 +1408,13 @@
@Override
public void updateNeighborsAt(BlockPos pos, Block block) {
@ -747,7 +748,7 @@
this.neighborUpdater.updateNeighborsAtExceptFromFacing(pos, sourceBlock, (Direction) null, orientation);
}
@@ -1126,9 +1449,20 @@
@@ -1126,9 +1450,20 @@
@Override
public void explode(@Nullable Entity entity, @Nullable DamageSource damageSource, @Nullable ExplosionDamageCalculator behavior, double x, double y, double z, float power, boolean createFire, Level.ExplosionInteraction explosionSourceType, ParticleOptions smallParticle, ParticleOptions largeParticle, Holder<SoundEvent> soundEvent) {
@ -769,7 +770,7 @@
case NONE:
explosion_effect = Explosion.BlockInteraction.KEEP;
break;
@@ -1144,16 +1478,27 @@
@@ -1144,16 +1479,27 @@
case TRIGGER:
explosion_effect = Explosion.BlockInteraction.TRIGGER_BLOCK;
break;
@ -800,7 +801,7 @@
Iterator iterator = this.players.iterator();
while (iterator.hasNext()) {
@@ -1162,10 +1507,11 @@
@@ -1162,10 +1508,11 @@
if (entityplayer.distanceToSqr(vec3d) < 4096.0D) {
Optional<Vec3> optional = Optional.ofNullable((Vec3) serverexplosion.getHitPlayers().get(entityplayer));
@ -813,7 +814,7 @@
}
private Explosion.BlockInteraction getDestroyType(GameRules.Key<GameRules.BooleanValue> decayRule) {
@@ -1226,17 +1572,29 @@
@@ -1226,17 +1573,29 @@
}
public <T extends ParticleOptions> int sendParticles(T parameters, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double speed) {
@ -848,7 +849,7 @@
++j;
}
}
@@ -1292,7 +1650,7 @@
@@ -1292,7 +1651,7 @@
@Nullable
public BlockPos findNearestMapStructure(TagKey<Structure> structureTag, BlockPos pos, int radius, boolean skipReferencedStructures) {
@ -857,7 +858,7 @@
return null;
} else {
Optional<HolderSet.Named<Structure>> optional = this.registryAccess().lookupOrThrow(Registries.STRUCTURE).get(structureTag);
@@ -1334,11 +1692,22 @@
@@ -1334,11 +1693,22 @@
@Nullable
@Override
public MapItemSavedData getMapData(MapId id) {
@ -881,7 +882,7 @@
this.getServer().overworld().getDataStorage().set(id.key(), state);
}
@@ -1352,7 +1721,9 @@
@@ -1352,7 +1722,9 @@
float f1 = this.levelData.getSpawnAngle();
if (!blockposition1.equals(pos) || f1 != angle) {
@ -891,7 +892,7 @@
this.getServer().getPlayerList().broadcastAll(new ClientboundSetDefaultSpawnPositionPacket(pos, angle));
}
@@ -1419,6 +1790,11 @@
@@ -1419,6 +1791,11 @@
});
optional1.ifPresent((holder) -> {
this.getServer().execute(() -> {
@ -903,7 +904,7 @@
this.getPoiManager().add(blockposition1, holder);
DebugPackets.sendPoiAddedPacket(this, blockposition1);
});
@@ -1649,6 +2025,11 @@
@@ -1649,6 +2026,11 @@
@Override
public void blockUpdated(BlockPos pos, Block block) {
if (!this.isDebug()) {
@ -915,7 +916,7 @@
this.updateNeighborsAt(pos, block);
}
@@ -1668,12 +2049,12 @@
@@ -1668,12 +2050,12 @@
}
public boolean isFlat() {
@ -930,7 +931,7 @@
}
@Nullable
@@ -1696,7 +2077,7 @@
@@ -1696,7 +2078,7 @@
private static <T> String getTypeCount(Iterable<T> items, Function<T, String> classifier) {
try {
Object2IntOpenHashMap<String> object2intopenhashmap = new Object2IntOpenHashMap();
@ -939,7 +940,7 @@
while (iterator.hasNext()) {
T t0 = iterator.next();
@@ -1705,7 +2086,7 @@
@@ -1705,7 +2087,7 @@
object2intopenhashmap.addTo(s, 1);
}
@ -948,7 +949,7 @@
String s1 = (String) entry.getKey();
return s1 + ":" + entry.getIntValue();
@@ -1717,6 +2098,7 @@
@@ -1717,6 +2099,7 @@
@Override
public LevelEntityGetter<Entity> getEntities() {
@ -956,7 +957,7 @@
return this.entityManager.getEntityGetter();
}
@@ -1802,6 +2184,17 @@
@@ -1802,6 +2185,17 @@
return this.serverLevelData.getGameRules();
}
@ -974,7 +975,7 @@
@Override
public CrashReportCategory fillReportDetails(CrashReport report) {
CrashReportCategory crashreportsystemdetails = super.fillReportDetails(report);
@@ -1836,7 +2229,8 @@
@@ -1836,7 +2230,8 @@
}
public void onTrackingStart(Entity entity) {
@ -984,7 +985,7 @@
if (entity instanceof ServerPlayer entityplayer) {
ServerLevel.this.players.add(entityplayer);
ServerLevel.this.updateSleepingPlayerList();
@@ -1864,9 +2258,53 @@
@@ -1864,9 +2259,53 @@
}
entity.updateDynamicGameEventListener(DynamicGameEventListener::add);
@ -1038,7 +1039,7 @@
ServerLevel.this.getChunkSource().removeEntity(entity);
if (entity instanceof ServerPlayer entityplayer) {
ServerLevel.this.players.remove(entityplayer);
@@ -1895,6 +2333,15 @@
@@ -1895,6 +2334,15 @@
}
entity.updateDynamicGameEventListener(DynamicGameEventListener::remove);

View File

@ -66,7 +66,7 @@
public int lastHurtByPlayerTime;
protected boolean dead;
protected int noActionTime;
@@ -260,6 +285,28 @@
@@ -260,7 +285,29 @@
protected boolean skipDropExperience;
private final EnumMap<EquipmentSlot, Reference2ObjectMap<Enchantment, Set<EnchantmentLocationBasedEffect>>> activeLocationDependentEnchantments;
protected float appliedScale;
@ -79,7 +79,7 @@
+ public boolean bukkitPickUpLoot;
+ public org.bukkit.craftbukkit.entity.CraftLivingEntity getBukkitLivingEntity() { return (org.bukkit.craftbukkit.entity.CraftLivingEntity) super.getBukkitEntity(); } // Paper
+ public boolean silentDeath = false; // Paper - mark entity as dying silently for cancellable death event
+
+ @Override
+ public float getBukkitYaw() {
+ return this.getYHeadRot();
@ -92,9 +92,10 @@
+ ++this.noActionTime; // Above all the floats
+ }
+ // Spigot end
+
protected LivingEntity(EntityType<? extends LivingEntity> type, Level world) {
super(type, world);
this.lastHandItemStacks = NonNullList.withSize(2, ItemStack.EMPTY);
@@ -276,7 +323,9 @@
this.activeLocationDependentEnchantments = new EnumMap(EquipmentSlot.class);
this.appliedScale = 1.0F;
@ -442,7 +443,7 @@
return flag;
}
}
@@ -1031,14 +1208,40 @@
@@ -1031,13 +1208,39 @@
return this.getType().is(EntityTypeTags.INVERTED_HEALING_AND_HARM);
}
@ -477,14 +478,13 @@
- MobEffectInstance mobeffect = this.removeEffectNoUpdate(effect);
+ return this.removeEffect(effect, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.UNKNOWN);
+ }
+
+ public boolean removeEffect(Holder<MobEffect> holder, EntityPotionEffectEvent.Cause cause) {
+ MobEffectInstance mobeffect = this.removeEffectNoUpdate(holder, cause);
+ // CraftBukkit end
+
if (mobeffect != null) {
this.onEffectsRemoved(List.of(mobeffect));
return true;
@@ -1142,20 +1345,65 @@
}
@ -1236,27 +1236,26 @@
}
public CombatTracker getCombatTracker() {
@@ -1935,9 +2502,19 @@
@@ -1935,8 +2502,18 @@
}
public final void setArrowCount(int stuckArrowCount) {
- this.entityData.set(LivingEntity.DATA_ARROW_COUNT_ID, stuckArrowCount);
+ // CraftBukkit start
+ this.setArrowCount(stuckArrowCount, false);
}
+ }
+
+ public final void setArrowCount(int i, boolean flag) {
+ ArrowBodyCountChangeEvent event = CraftEventFactory.callArrowBodyCountChangeEvent(this, this.getArrowCount(), i, flag);
+ if (event.isCancelled()) {
+ return;
+ }
+ this.entityData.set(LivingEntity.DATA_ARROW_COUNT_ID, event.getNewAmount());
+ }
}
+ // CraftBukkit end
+
public final int getStingerCount() {
return (Integer) this.entityData.get(LivingEntity.DATA_STINGER_COUNT_ID);
}
@@ -1999,7 +2576,7 @@
this.playSound(soundeffect, this.getSoundVolume(), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
}
@ -1266,19 +1265,19 @@
this.setHealth(0.0F);
this.die(this.damageSources().generic());
}
@@ -2181,6 +2758,12 @@
public abstract Iterable<ItemStack> getArmorSlots();
@@ -2182,6 +2759,12 @@
public abstract ItemStack getItemBySlot(EquipmentSlot slot);
+
+ // CraftBukkit start
+ public void setItemSlot(EquipmentSlot enumitemslot, ItemStack itemstack, boolean silent) {
+ this.setItemSlot(enumitemslot, itemstack);
+ }
+ // CraftBukkit end
+
public abstract void setItemSlot(EquipmentSlot slot, ItemStack stack);
public Iterable<ItemStack> getHandSlots() {
@@ -2494,7 +3077,7 @@
}
@ -1381,7 +1380,28 @@
if (this.isAlive()) {
this.travelRidden(entityhuman, vec3d1);
break label112;
@@ -3063,6 +3655,7 @@
@@ -3046,6 +3638,20 @@
this.pushEntities();
gameprofilerfiller.pop();
+ // Paper start - Add EntityMoveEvent
+ if (((ServerLevel) this.level()).hasEntityMoveEvent && !(this instanceof net.minecraft.world.entity.player.Player)) {
+ if (this.xo != this.getX() || this.yo != this.getY() || this.zo != this.getZ() || this.yRotO != this.getYRot() || this.xRotO != this.getXRot()) {
+ Location from = new Location(this.level().getWorld(), this.xo, this.yo, this.zo, this.yRotO, this.xRotO);
+ Location to = new Location(this.level().getWorld(), this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot());
+ io.papermc.paper.event.entity.EntityMoveEvent event = new io.papermc.paper.event.entity.EntityMoveEvent(this.getBukkitLivingEntity(), from, to.clone());
+ if (!event.callEvent()) {
+ this.absMoveTo(from.getX(), from.getY(), from.getZ(), from.getYaw(), from.getPitch());
+ } else if (!to.equals(event.getTo())) {
+ this.absMoveTo(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ(), event.getTo().getYaw(), event.getTo().getPitch());
+ }
+ }
+ }
+ // Paper end - Add EntityMoveEvent
world = this.level();
if (world instanceof ServerLevel worldserver) {
if (this.isSensitiveToWater() && this.isInWaterRainOrBubble()) {
@@ -3063,6 +3669,7 @@
this.checkSlowFallDistance();
if (!this.level().isClientSide) {
if (!this.canGlide()) {
@ -1389,7 +1409,7 @@
this.setSharedFlag(7, false);
return;
}
@@ -3113,12 +3706,26 @@
@@ -3113,12 +3720,26 @@
Level world = this.level();
if (!(world instanceof ServerLevel worldserver)) {
@ -1419,7 +1439,7 @@
if (i > 0 && list.size() > i - 1 && this.random.nextInt(4) == 0) {
int j = 0;
@@ -3138,10 +3745,12 @@
@@ -3138,10 +3759,12 @@
}
Iterator iterator1 = list.iterator();
@ -1434,7 +1454,7 @@
this.doPush(entity1);
}
}
@@ -3190,10 +3799,16 @@
@@ -3190,10 +3813,16 @@
@Override
public void stopRiding() {
@ -1453,7 +1473,7 @@
this.dismountVehicle(entity);
}
@@ -3305,15 +3920,29 @@
@@ -3305,15 +3934,29 @@
@Override
public boolean isPickable() {
@ -1485,7 +1505,7 @@
public float getYHeadRot() {
return this.yHeadRot;
}
@@ -3342,7 +3971,7 @@
@@ -3342,7 +3985,7 @@
}
public final void setAbsorptionAmount(float absorptionAmount) {
@ -1494,7 +1514,7 @@
}
protected void internalSetAbsorptionAmount(float absorptionAmount) {
@@ -3410,9 +4039,14 @@
@@ -3410,9 +4053,14 @@
}
public void startUsingItem(InteractionHand hand) {
@ -1510,7 +1530,7 @@
this.useItem = itemstack;
this.useItemRemaining = itemstack.getUseDuration(this);
if (!this.level().isClientSide) {
@@ -3483,13 +4117,49 @@
@@ -3483,13 +4131,49 @@
this.releaseUsingItem();
} else {
if (!this.useItem.isEmpty() && this.isUsingItem()) {
@ -1524,7 +1544,7 @@
+ org.bukkit.inventory.EquipmentSlot hand = org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(enumhand);
+ event = new PlayerItemConsumeEvent((Player) this.getBukkitEntity(), craftItem, hand); // Paper
+ this.level().getCraftServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ // Update client
+ Consumable consumable = this.useItem.get(DataComponents.CONSUMABLE);
@ -1547,7 +1567,7 @@
+ }
+ // Paper end
+ // CraftBukkit end
+
if (itemstack != this.useItem) {
this.setItemInHand(enumhand, itemstack);
}
@ -1561,7 +1581,7 @@
}
}
@@ -3544,11 +4214,68 @@
@@ -3544,12 +4228,69 @@
if (this.isUsingItem() && !this.useItem.isEmpty()) {
Item item = this.useItem.getItem();
@ -1571,7 +1591,7 @@
return null;
}
}
+
+ // Paper start - Make shield blocking delay configurable
+ public HitResult getRayTrace(int maxDistance, ClipContext.Fluid fluidCollisionOption) {
+ if (maxDistance < 1 || maxDistance > 120) {
@ -1628,10 +1648,11 @@
+ this.shieldBlockingDelay = shieldBlockingDelay;
+ }
+ // Paper end - Make shield blocking delay configurable
+
public boolean isSuppressingSlidingDownLadder() {
return this.isShiftKeyDown();
@@ -3568,12 +4295,18 @@
}
@@ -3568,12 +4309,18 @@
}
public boolean randomTeleport(double x, double y, double z, boolean particleEffects) {
@ -1652,7 +1673,7 @@
Level world = this.level();
if (world.hasChunkAt(blockposition)) {
@@ -3592,18 +4325,43 @@
@@ -3592,18 +4339,43 @@
}
if (flag2) {
@ -1664,7 +1685,7 @@
+ this.setPos(d0, d6, d2);
if (world.noCollision((Entity) this) && !world.containsAnyLiquid(this.getBoundingBox())) {
flag1 = true;
}
+ }
+ // now revert and call event if the teleport place is valid
+ this.setPos(d3, d4, d5);
+
@ -1684,7 +1705,7 @@
+ return Optional.empty();
+ }
+ }
+ }
}
+ // CraftBukkit end
}
}
@ -1700,7 +1721,7 @@
world.broadcastEntityEvent(this, (byte) 46);
}
@@ -3613,7 +4371,7 @@
@@ -3613,7 +4385,7 @@
entitycreature.getNavigation().stop();
}
@ -1709,7 +1730,7 @@
}
}
@@ -3706,7 +4464,7 @@
@@ -3706,7 +4478,7 @@
}
public void stopSleeping() {
@ -1718,7 +1739,7 @@
Level world = this.level();
java.util.Objects.requireNonNull(world);
@@ -3718,9 +4476,9 @@
@@ -3718,9 +4490,9 @@
this.level().setBlock(blockposition, (BlockState) iblockdata.setValue(BedBlock.OCCUPIED, false), 3);
Vec3 vec3d = (Vec3) BedBlock.findStandUpPosition(this.getType(), this.level(), blockposition, enumdirection, this.getYRot()).orElseGet(() -> {
@ -1730,7 +1751,7 @@
});
Vec3 vec3d1 = Vec3.atBottomCenterOf(blockposition).subtract(vec3d).normalize();
float f = (float) Mth.wrapDegrees(Mth.atan2(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D);
@@ -3740,7 +4498,7 @@
@@ -3740,7 +4512,7 @@
@Nullable
public Direction getBedOrientation() {
@ -1739,7 +1760,7 @@
return blockposition != null ? BedBlock.getBedOrientation(this.level(), blockposition) : null;
}
@@ -3905,7 +4663,7 @@
@@ -3905,7 +4677,7 @@
public float maxUpStep() {
float f = (float) this.getAttributeValue(Attributes.STEP_HEIGHT);