Files
ParchmentMC/patches/server/0019-Expanded-Insomnia-API.patch
Lexi Larkin 930b419022 Updated Upstream (Paper)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
PaperMC/Paper@bd496d0 [ci skip] shuffle patches and rebuild
PaperMC/Paper@79f2aa3 Update Velocity natives (#8387)
PaperMC/Paper@21661a7 Fix jigsaw block kicking user (#8404)
PaperMC/Paper@017af78 [ci skip] Added the missing "d" character (#8267)
PaperMC/Paper@8a7dd61 Mark parsed PoiChunks with data as not loaded (#8405)
PaperMC/Paper@7d3a882 Do not log throwable for duplicate entity adds
PaperMC/Paper@8d69cfc Reduce allocation rate for checkBlock
PaperMC/Paper@c6d7375 use BlockFormEvent for mud converting into clay (#8398)
PaperMC/Paper@14c32bc Fix wrong yaw and pitch of CommandSourceStack#getBukkitLocation (#8411)
PaperMC/Paper@f5fa691 Don't print full packages in new chunk system classes
PaperMC/Paper@2534e5c Fix other jigsaw related disconnect bug (#8414)
PaperMC/Paper@e9618f8 Add system property to dump stack on bad plugin class access (#8417)
PaperMC/Paper@6d14093 Add getDrops to BlockState and isPreferredTool to BlockData (#8284)
PaperMC/Paper@ec76e36 Fix a handful of vanilla bugs (#8187)
PaperMC/Paper@ec3cfa9 Only create paper.yml-README.txt on config conversion (#8334)
PaperMC/Paper@928bcc8 Updated Upstream (Bukkit/CraftBukkit) (#8430)
PaperMC/Paper@616db71 Fix nothing mlg (#8432)
PaperMC/Paper@011caa4 [ci skip] Minor patch cleanup
PaperMC/Paper@15e1748 Avoid resizing of ArrayList in ChunkMap#getPlayers (#8416)
PaperMC/Paper@ad3d357 Remove unnecessary onTrackingStart during nav warning
PaperMC/Paper@9d63b07 Fix custom piglin interest items (#8097)
PaperMC/Paper@ff67f1f EntityPickupItemEvent fixes (#8096)
PaperMC/Paper@bcb4220 Correctly handle interactions with items on cooldown (#8008)
PaperMC/Paper@60c973e Exempt players in creative/spectator from nether ceiling damage (#8427)
PaperMC/Paper@77a50b9 Add Unmodifiable annotations to getDrops methods (#8440)
PaperMC/Paper@c389b1c Fix configs that relied on outdated min/max y levels (#6986)
PaperMC/Paper@57555b8 Add missing structure set seed configs (#8030)
PaperMC/Paper@b097a24 Expose isUnderWater to Entity (#8454)
PaperMC/Paper@6b26cfc Add missing Entity + Projectile API (#7632)
PaperMC/Paper@de2d2d4 Add PlayerInventorySlotChangeEvent (#7321)
PaperMC/Paper@f7c8d79 Fix stacktrace in server tests
PaperMC/Paper@b9cf1ac Fix a classloading issue in tests (#8459)
PaperMC/Paper@7fe34e9 Make CraftMinecartTNT public
PaperMC/Paper@514a606 Elder Guardian appearance API (#8455)
PaperMC/Paper@2094011 Update settings directory path in exceptions (#7968)
PaperMC/Paper@0bdf997 Avoid cycle deprecation (#8466)
PaperMC/Paper@eb68bd4 Allow changing bed's 'occupied' property (#8458)
PaperMC/Paper@b560034 Avoid usages of RecipeChoice#getItemStack() (#8453)
PaperMC/Paper@603df98 FIx bedrock patterns (#8474)
PaperMC/Paper@ec00f99 Fix package for PlayerInventorySlotChangeEvent (#8475)
PaperMC/Paper@236a296 Add LivingEntity#swingHand(EquipmentSlot) convenience method (#8456)
PaperMC/Paper@7d64d7c Add converted Slot number to PlayerInventorySlotChangeEvent (#8482)
PaperMC/Paper@ed2c88b Add LivingEntity knockback API (#8479)
PaperMC/Paper@e1d4b26 Fix another case of missing chat headers
PaperMC/Paper@f7da209 Fix inconsistent isChunkLoaded calls
PaperMC/Paper@3dcfec4 Add stacktrace deobfuscation in more places (#8484)
PaperMC/Paper@eb49418 [ci skip] Update workflow dependencies (#8489)
PaperMC/Paper@a163a96 Load Allay duplication cooldown as a long (#8410)
PaperMC/Paper@7187cab Detect headless JREs (#8491)
PaperMC/Paper@60da35e fixed entity vehicle collision event not called (#5053)
PaperMC/Paper@5cdb5f9 Optimized dirt and snow spreading (#5124)
PaperMC/Paper@3d50709 Add MaterialTags for the different Types of Tools (#8049)
PaperMC/Paper@6ea5aa3 Added EntityToggleSitEvent (#7579)
PaperMC/Paper@58483c1 Add fire-tick-delay option (#8037)
PaperMC/Paper@4e67c73 Add config setting for grindstone overstacking (#8156)
PaperMC/Paper@d713b47 Add EquipmentSlot convenience methods (#8477)
PaperMC/Paper@6665076 Add Moving Piston API (#7019)
PaperMC/Paper@0b8f40c Don't fire EntityToggleSitEvent on deserialization & reorder some api patches (#8495)
PaperMC/Paper@05bd9d6 Ignore impossible spawn tick (#8493)
PaperMC/Paper@b8131a0 Mark chunks as saved after saving them
PaperMC/Paper@44ce9b3 Updated Upstream (Bukkit/Spigot) (#8445)
PaperMC/Paper@1c1aeb2 Only limit global sounds to same world if limiting radius (#8499)
PaperMC/Paper@519cb4b Move classes added to net.minecraft.server to paper packages (#8500)
PaperMC/Paper@fc5ae5b Fix incorrect handling of mustNotSave
PaperMC/Paper@25cd3ee Add dirty flag to chunk tick lists
PaperMC/Paper@7b3b593 [ci skip] Update checkout action in workflow (#8510)
PaperMC/Paper@36869cc Fix new block data in EntityChangeBlockEvent for silverfish when mobGriefing isn't enabled (#8099)
PaperMC/Paper@2432233 Add allow server listing & text filtering client options (#7595)
PaperMC/Paper@954e6f0 Fix a bunch more forceDrops for dropping items (#8095)
PaperMC/Paper@32d95e9 Track projectile source for fireworks from dispensers (#8044)
PaperMC/Paper@0249750 Fix EntityArgument suggestion permissions to align with  EntitySelector#checkPermissions (#8511)
PaperMC/Paper@8acb05d Make CommandSyntaxException implement ComponentMessageThrowable (#8513)
PaperMC/Paper@c264018 [ci skip] Undo modification to removed patches in latest commit (#8512)
PaperMC/Paper@304ab35 [ci skip] Remove old todo file
PaperMC/Paper@8a4b752 Fix wrong descriptor in ASMEventExecutorGenerator (#8506)
PaperMC/Paper@b743144 Fix MC-147659 (#8423)
PaperMC/Paper@aaf5e39 Deprecate unused VehicleEntityCollisionEvent methods (#8498)
PaperMC/Paper@13cf546 Fix pumpkin growth modifier (#8517)
PaperMC/Paper@b3b04f2 Updated Upstream (Bukkit/CraftBukkit/Spigot) (#8515)
PaperMC/Paper@93b2246 Fix EntityCombustEvent cancellation issues (#8529)
PaperMC/Paper@4a9c9b3 Build updates
PaperMC/Paper@e30b082 Fix setting difficulity inside of API (Fixes #8533)
PaperMC/Paper@ebc0f6b Call PlayerLaunchProjectileEvent for trident (#8027)
PaperMC/Paper@ab1c072 Remove old redundant fix (#8530)
PaperMC/Paper@8ee344f [ci-skip] Rename Paper stop tp Paper end. (#8539)
PaperMC/Paper@3d15120 Fix Advancement#getDisplay() api break (#8541)
PaperMC/Paper@2b47227 Update Commodore modifications (#8542)
PaperMC/Paper@df5fb94 Properly resend entities (#7041)
PaperMC/Paper@3e9f39f Prevent compass from loading chunks
PaperMC/Paper@3ac1a8d Cleanup misc import from last commit
PaperMC/Paper@e6ee4cd Updated Upstream (CraftBukkit) (#8548)
PaperMC/Paper@117579c Add PrePlayerAttackEntityEvent (#8369)
PaperMC/Paper@112fa18 Show exception when headless JRE detection is triggered (#8559)
PaperMC/Paper@5f4952f Cleanup reputation API + back with an EnumMap instead of array (#8258)
PaperMC/Paper@564356d ensure reset EnderDragon boss event name (#8562)
PaperMC/Paper@7955bcc fix MC-252817 (green map markers do not dissappear) (#8545)
PaperMC/Paper@e22dacf update yarn param mappings (#8563)
PaperMC/Paper@2151112 Fix/improve Affects Spawning API (#7329)
PaperMC/Paper@84b5d4a Reorder bukkit damage source entity for explosion (#8553)
PaperMC/Paper@b4c1ae6 Fix MC-121048 (#8429)
PaperMC/Paper@825cb43 [ci skip] Add .fleet/ folder to .gitignore (#8574)
PaperMC/Paper@669fed4 Fix MC-179072 (#8421)
PaperMC/Paper@8f498dc Sync chunk load command improvements (#8554)
PaperMC/Paper@3299886 [ci skip] Add TheFruxz to the license MIT list (#8575)
PaperMC/Paper@0a6f100 Add more collision code skipping logic (#7581)
PaperMC/Paper@76503f8 Strip coordinates from lodestone compasses (#8561)
PaperMC/Paper@b95d4b2 Moving ATs from the at file to individual patches (#8573)
PaperMC/Paper@4a3ae59 [ci skip] Add check for git repo (#8578)
PaperMC/Paper@a7df847 Add Player Warden Warning API (#8470)
PaperMC/Paper@3ab194e Avoid a cubed max search distance for POIs (#8576)
PaperMC/Paper@55a16d8 Fix Varint21FrameDecoder cached length buf usage
PaperMC/Paper@e6e37ba Add api to resolve components (#7648)
PaperMC/Paper@7168438 [ci skip] Rework workflows to support optional paperclip build (#8583)
PaperMC/Paper@da230d5 More vanilla friendly methods to update trades (#8478)
PaperMC/Paper@8aff07a Add /paper dumplisteners command (#8507)
PaperMC/Paper@b8919a7 pr command action fixes (#8591)
PaperMC/Paper@185fa48 Fix chest relooting mechanics (#8580)
PaperMC/Paper@b4beac0 Fixes potential issues arising from optimizing getPlayerByUUID (#8585)
PaperMC/Paper@f637b1a Fix async entity add due to fungus trees (#7626)
PaperMC/Paper@414ea80 ItemStack damage API (#7801)
PaperMC/Paper@d98c370 Add displayName methods for advancements (#8584)
PaperMC/Paper@44bb599 Add Tick TemporalUnit (#5445)
PaperMC/Paper@9f7eef8 Friction API (#6611)
PaperMC/Paper@4048d3e Allow using degrees for ArmorStand rotations (#7847)
PaperMC/Paper@f59c802 Schoolable Fish API (#7089)
PaperMC/Paper@21b964a Added ability to control player's insomnia and phantoms spawning (#6500)
PaperMC/Paper@f1583fc Add `/paper dumplisteners tofile` and increase detail of command output (#8592)
PaperMC/Paper@28b4027 Fix packet duplicating at some points (#8566)
PaperMC/Paper@309133e Fix preemptive connection dropping during shutdown process (#8546)
PaperMC/Paper@8796175 Handle legacy quirk in the console formatter (#8434)
PaperMC/Paper@54daefa Fix whitespace error in recent patch
PaperMC/Paper@41ab602 [ci skip] couple more fixes for build pr jar label (#8599)
PaperMC/Paper@c40f8d5 Sync offhand slot in menus (#7341)
PaperMC/Paper@425baed Fully deserialise persistent anger post async load (#8560)
PaperMC/Paper@ec6a9a3 Updated Upstream (Bukkit/CraftBukkit) (#8604)
PaperMC/Paper@96fdafd Player Entity Tracking Events (#4722)
PaperMC/Paper@407a445 Fix dumplisteners missing folder creation
PaperMC/Paper@b07d5e0 Limit pet look distance (#8612)
PaperMC/Paper@476ef25 Add missing Fluid type (#8608)
2022-12-06 16:54:38 -05:00

91 lines
4.3 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Blast-MC <cjblanton2@gmail.com>
Date: Sun, 24 Jul 2022 19:37:33 -0400
Subject: [PATCH] Expanded Insomnia API
diff --git a/src/main/java/net/minecraft/world/entity/EntitySelector.java b/src/main/java/net/minecraft/world/entity/EntitySelector.java
index 72abebff2018cde2922e97ad6478f93da9aed3ec..c541e80f7ab6772bdd4074f5df7075502b144a31 100644
--- a/src/main/java/net/minecraft/world/entity/EntitySelector.java
+++ b/src/main/java/net/minecraft/world/entity/EntitySelector.java
@@ -36,6 +36,12 @@ public final class EntitySelector {
return false;
}
+ // Parchment start
+ if (((org.bukkit.entity.Player) player.getBukkitEntity()).doesBypassInsomnia()) {
+ return false;
+ }
+ // Parchment end
+
return net.minecraft.util.Mth.clamp(serverPlayer.getStats().getValue(net.minecraft.stats.Stats.CUSTOM.get(net.minecraft.stats.Stats.TIME_SINCE_REST)), 1, Integer.MAX_VALUE) >= playerInsomniaTicks;
};
// Paper end
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
index cf41ff3be41b576123457bcb1e613378b6cce4de..853deb219785787f78c6eecad6237893eba9f03f 100644
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
@@ -294,7 +294,7 @@ public abstract class Player extends LivingEntity {
this.awardStat(Stats.CROUCH_TIME);
}
- if (!this.isSleeping() && this.level.paperConfig().entities.behavior.tickTimeSinceSleep) { // Parchment
+ if (!this.isSleeping() && this.level.paperConfig().entities.behavior.tickTimeSinceSleep && !((org.bukkit.entity.Player) this.getBukkitEntity()).doesBypassInsomnia()) { // Parchment
this.awardStat(Stats.TIME_SINCE_REST);
}
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 0950b5f97b3382d1e41da9837e1e0b7cce6ba1b4..b209c1b2e9a877af830c022756fd60c8c65ea8dd 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -73,6 +73,7 @@ import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.network.ServerGamePacketListenerImpl;
import net.minecraft.server.players.UserWhiteListEntry;
import net.minecraft.world.entity.Entity;
+import net.minecraft.world.entity.EntitySelector;
import net.minecraft.world.entity.ai.attributes.AttributeInstance;
import net.minecraft.world.entity.ai.attributes.AttributeMap;
import net.minecraft.world.entity.ai.attributes.Attributes;
@@ -176,6 +177,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
private static final boolean DISABLE_CHANNEL_LIMIT = System.getProperty("paper.disableChannelLimit") != null; // Paper - add a flag to disable the channel limit
private long lastSaveTime;
// Paper end
+ private boolean bypassesInsomnia = false;
public CraftPlayer(CraftServer server, ServerPlayer entity) {
super(server, entity);
@@ -1915,6 +1917,33 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
return this;
}
+ // Parchment start
+ @Override
+ public boolean isInsomniac() {
+ return EntitySelector.isInsomniac.test(this.getHandle());
+ }
+
+ @Override
+ public void setBypassInsomnia(boolean val) {
+ this.bypassesInsomnia = val;
+ }
+
+ @Override
+ public boolean doesBypassInsomnia() {
+ return this.bypassesInsomnia;
+ }
+
+ @Override
+ public void setTimeSinceLastRest(int ticks) {
+ this.getHandle().getStats().setValue(this.getHandle(), net.minecraft.stats.Stats.CUSTOM.get(net.minecraft.stats.Stats.TIME_SINCE_REST), net.minecraft.util.Mth.clamp(ticks, 1, Integer.MAX_VALUE));
+ }
+
+ @Override
+ public int getTimeSinceLastRest() {
+ return net.minecraft.util.Mth.clamp(this.getHandle().getStats().getValue(net.minecraft.stats.Stats.CUSTOM.get(net.minecraft.stats.Stats.TIME_SINCE_REST)), 1, Integer.MAX_VALUE);
+ }
+ // Parchment end
+
@Override
public ServerPlayer getHandle() {
return (ServerPlayer) entity;