Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ketting Builds #13

Merged
merged 30 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
a8074a4
Ambient entity patches
TonimatasDEV Nov 14, 2023
21c2b0d
Raid entity patches
TonimatasDEV Nov 14, 2023
2067f3b
Projectile entity patches
TonimatasDEV Nov 14, 2023
457477d
NPC entity patches
TonimatasDEV Nov 14, 2023
75d2fed
Item entity patches
TonimatasDEV Nov 14, 2023
098f999
Player entity patches
TonimatasDEV Nov 14, 2023
2d931ec
Boss entity patches
TonimatasDEV Nov 14, 2023
e4d0402
Merge pull request #1 from kettingpowered/1.20.x
TonimatasDEV Nov 14, 2023
33d1e37
Decoration entity patches
TonimatasDEV Nov 14, 2023
b182856
Merge pull request #2 from kettingpowered/1.20.x
TonimatasDEV Nov 14, 2023
f380d1d
Vehicle entity patches
TonimatasDEV Nov 14, 2023
4436d37
Base animal patches
TonimatasDEV Nov 14, 2023
4121a37
Sniffer animal patches
TonimatasDEV Nov 14, 2023
6c1d9d6
Horse animal patches
TonimatasDEV Nov 14, 2023
8206bca
Allay, Axolotl, Goat and Frog animal patches
TonimatasDEV Nov 14, 2023
98f651a
Base monster patches
TonimatasDEV Nov 14, 2023
6884264
[skip ci] Warden monster patches
TonimatasDEV Nov 14, 2023
0403a2c
Piglin monster patches
TonimatasDEV Nov 14, 2023
df9b489
Update forge to 48.0.34
JustRed23 Nov 15, 2023
2a58c9e
Update forge to 48.0.35
JustRed23 Nov 15, 2023
f51a9c7
Update forge to 48.0.36
JustRed23 Nov 15, 2023
7dff603
Update forge to 48.0.37
JustRed23 Nov 15, 2023
bc8898c
Update forge to 48.0.38
JustRed23 Nov 15, 2023
b3b59fc
[skip ci] add build status
JustRed23 Nov 15, 2023
15b11bc
Update README.md
JustRed23 Nov 15, 2023
3450413
Merge pull request #3 from kettingpowered/1.20.x
TonimatasDEV Nov 15, 2023
994bbcd
Merge pull request #8 from TonimatasDEV/1.20.x
JustRed23 Nov 16, 2023
757c70c
[skip ci] fix ambient entity patches
JustRed23 Nov 16, 2023
8390982
[skip ci] fix boss entity patches
JustRed23 Nov 16, 2023
a59203a
[skip ci] update readme
JustRed23 Nov 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import de.undercouch.gradle.tasks.download.Download
import groovy.json.JsonBuilder
import net.minecraftforge.forge.tasks.checks.CheckATs
import net.minecraftforge.forge.tasks.checks.CheckExcs
Expand Down Expand Up @@ -28,8 +29,8 @@ plugins {
id 'net.minecraftforge.gradleutils' version '2.1.3'
id 'eclipse'
id 'de.undercouch.download' version '5.4.0'
id 'net.minecraftforge.gradle.patcher' version '[6.0.14,6.2)' apply false
id 'net.minecraftforge.gradle.mcp' version '[6.0.14,6.2)' apply false
id 'net.minecraftforge.gradle.patcher' version '[6.0.16,6.2)' apply false
id 'net.minecraftforge.gradle.mcp' version '[6.0.16,6.2)' apply false
id "dev.vankka.dependencydownload.plugin" version "1.3.1" apply false
}

Expand All @@ -54,7 +55,7 @@ ext {
INSTALLER_VERSION = '2.1.+'

GIT_INFO = gradleutils.gitInfo
FORGE_VERSION = "48.0.33"
FORGE_VERSION = "48.0.38"
VERSION = "${MC_VERSION}-${FORGE_VERSION}"
KETTING_VERSION = "${VERSION}-${GIT_INFO.abbreviatedId}"

Expand Down
4 changes: 2 additions & 2 deletions build_clean.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
plugins {
id 'org.cadixdev.licenser'
id 'java-library'
id 'eclipse'
id 'net.minecraftforge.gradle.patcher' version '[6.0.14,6.2)'
id 'net.minecraftforge.gradle.patcher' version '[6.0.16,6.2)'
}

evaluationDependsOn(':mcp')
Expand Down Expand Up @@ -44,6 +43,7 @@ patcher {
}
}
}

eclipse.classpath.file.whenMerged {
// Disable optional warnings on the minecraft decompiled source code. It just muddies the warning window and hides warnings in our own codebase
def src = entries.find { it.path == 'src/main/java' }
Expand Down
11 changes: 7 additions & 4 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
[discord-widget]: https://canary.discord.com/api/guilds/1172551819138965605/widget.png
[discord-invite]: https://discord.gg/jBHZDG9WS8
[forge-version]: https://img.shields.io/badge/1.20.2--48.0.33-none?logo=data%3Aimage%2Fpng%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8%2F9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAZdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuMjCGJ1kDAAACoElEQVQ4T22SeU8aURTF%2FULGtNRWWVQY9lXABWldIDPIMgVbNgEVtaa0damiqGBdipXaJcY2ofEf4ycbTt97pVAabzK5b27u%2BZ377kwXgK77QthRy7OfXbeJM%2BttqKSXN8sdwbT%2FA0L7elmsYqrPHZmROLPh5YkV4oEBwaKuHj%2ByyJptLDoAhbq3O1V1XCVObY3FL24mfn5oRPrcwSCRfQOyNWcjVjZdCbtcdwcgXrXUspdOKbDN%2FXE9tiBJMhXHT60gUIT2dMhcDLMc3NVKQklz0QIkf5qlyEcO6Qs7yPhMJB4amDMFimQSmqNlE8SKAZFzDfxHfVILIIZ10sJ3OwIbcqSuiOjchkzNCboHev9o2YhgiUP8mxnLN24I6%2F3ghYdtQG5iUMpFBuCP9iKwLsfiLyeCp2rMnZgwX3NArGoxW1Ridl%2BBzLEVKa8KSxOqNmDdz0kFnxaLHhWEgAyZigWhHXL%2BpEDy2ozsDxv8vAzTnh7w5kcghqCaFmCT10of4iPIT2mRdPUh4HoCcVwBH%2F8Ac2kzUkEV5r3EfVSOvbAJa5NDyI0r2oDtWb1EClh%2BOoC3Pg7v%2FBw7p939yI4rsRW2Y3lKh01eh7WpIRyKZqzyjjYgPdIvlaMWRqYuG7wWryYHsRM0sFolZiPvQ3jheIwSmSBPdkByG%2FB6Wi3RYiVmRX7GiAPiUCRisii8D%2BjZNKvPBrHCW1GY0bAz6WkDCtOaSyKQFsi4K5NqNiZtehN2Y5uAShETqolhBqJXpfdPuPsuWwAaRdHSkxdc11mPqkGnyY4pyKbpl1GyJ0Pel7yqBoFcF3zqno5f%2Bd8ohYy9Sx7lzQpxo1eirluCDgt%2B%2B00p6uxttrG4F%2FA39sJGZWZMfrcp6O6%2B5kaVzXJHAOj6DeSs8qw5o8oxAAAAAElFTkSuQmCC&labelColor=4e4e4e&color=2d2d2d
[forge-commit]: https://github.com/MinecraftForge/MinecraftForge/commit/7a44327
[forge-version]: https://img.shields.io/badge/1.20.2--48.0.38-none?logo=data%3Aimage%2Fpng%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8%2F9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAZdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuMjCGJ1kDAAACoElEQVQ4T22SeU8aURTF%2FULGtNRWWVQY9lXABWldIDPIMgVbNgEVtaa0damiqGBdipXaJcY2ofEf4ycbTt97pVAabzK5b27u%2BZ377kwXgK77QthRy7OfXbeJM%2BttqKSXN8sdwbT%2FA0L7elmsYqrPHZmROLPh5YkV4oEBwaKuHj%2ByyJptLDoAhbq3O1V1XCVObY3FL24mfn5oRPrcwSCRfQOyNWcjVjZdCbtcdwcgXrXUspdOKbDN%2FXE9tiBJMhXHT60gUIT2dMhcDLMc3NVKQklz0QIkf5qlyEcO6Qs7yPhMJB4amDMFimQSmqNlE8SKAZFzDfxHfVILIIZ10sJ3OwIbcqSuiOjchkzNCboHev9o2YhgiUP8mxnLN24I6%2F3ghYdtQG5iUMpFBuCP9iKwLsfiLyeCp2rMnZgwX3NArGoxW1Ridl%2BBzLEVKa8KSxOqNmDdz0kFnxaLHhWEgAyZigWhHXL%2BpEDy2ozsDxv8vAzTnh7w5kcghqCaFmCT10of4iPIT2mRdPUh4HoCcVwBH%2F8Ac2kzUkEV5r3EfVSOvbAJa5NDyI0r2oDtWb1EClh%2BOoC3Pg7v%2FBw7p939yI4rsRW2Y3lKh01eh7WpIRyKZqzyjjYgPdIvlaMWRqYuG7wWryYHsRM0sFolZiPvQ3jheIwSmSBPdkByG%2FB6Wi3RYiVmRX7GiAPiUCRisii8D%2BjZNKvPBrHCW1GY0bAz6WkDCtOaSyKQFsi4K5NqNiZtehN2Y5uAShETqolhBqJXpfdPuPsuWwAaRdHSkxdc11mPqkGnyY4pyKbpl1GyJ0Pel7yqBoFcF3zqno5f%2Bd8ohYy9Sx7lzQpxo1eirluCDgt%2B%2B00p6uxttrG4F%2FA39sJGZWZMfrcp6O6%2B5kaVzXJHAOj6DeSs8qw5o8oxAAAAAElFTkSuQmCC&labelColor=4e4e4e&color=2d2d2d
[forge-commit]: https://github.com/MinecraftForge/MinecraftForge/commit/83c651c
[build-status]: https://img.shields.io/github/actions/workflow/status/kettingpowered/Ketting-1-20-x/build_and_release.yml
[build-link]: https://github.com/kettingpowered/Ketting-1-20-x/actions

<img align="right" src="./assets/ketting.png?raw=true" height="150" width="150">

[![discord-widget][]][discord-invite]
[![forge-version][]][forge-commit]
[![build-status][]][build-link]

# Ketting

Expand All @@ -18,7 +21,7 @@ that enables the use of Bukkit plugins on Forge servers.
Ketting is still in development and is not ready for production use.

### PATCHES DONE
Bukkit: 291 / 530
Bukkit: 296 / 530
<br>
CraftBukkit: 0 / 685

Expand Down Expand Up @@ -63,7 +66,7 @@ Forge MDK from [their website](https://files.minecraftforge.net/net/minecraftfor
Ketting uses the Gradle build system, so you can build it by running the following command:

```bash
./gradlew build
./gradlew setup
```
To create a jar, run

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ public ModInfo(final ModFileInfo owningFile, final IConfigurable config)
this.displayName = config.<String>getConfigElement("displayName")
.orElse(this.modId);
this.description = config.<String>getConfigElement("description")
.orElse("MISSING DESCRIPTION");
.orElse("MISSING DESCRIPTION")
.replace("\r\n", "\n").stripIndent();
this.logoFile = Optional.ofNullable(config.<String>getConfigElement("logoFile")
.orElseGet(() -> ownFile.flatMap(mf -> mf.<String>getConfigElement("logoFile"))
.orElse(null)));
Expand Down Expand Up @@ -205,7 +206,7 @@ class ModVersion implements net.minecraftforge.forgespi.language.IModInfo.ModVer
private final boolean mandatory;
private final Ordering ordering;
private final DependencySide side;
private Optional<URL> referralUrl;
private final Optional<URL> referralUrl;

public ModVersion(final IModInfo owner, final IConfigurable config) {
this.owner = owner;
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 3 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionSha256Sum=e111cb9948407e26351227dabce49822fb88c37ee72f1d1582a69c68af2e702f
distributionSha256Sum=f2b9ed0faf8472cbe469255ae6c86eddb77076c75191741b4a462f33128dd419
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
29 changes: 17 additions & 12 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -133,26 +131,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then
done
fi

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
2 changes: 1 addition & 1 deletion patches/minecraft/net/minecraft/tags/TagLoader.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

private Either<Collection<TagLoader.EntryWithSource>, Collection<T>> build(TagEntry.Lookup<T> p_215979_, List<TagLoader.EntryWithSource> p_215980_) {
- ImmutableSet.Builder<T> builder = ImmutableSet.builder();
+ var builder = new java.util.HashSet<T>();
+ var builder = new java.util.LinkedHashSet<T>(); // Order is important, as ImmutableSet is ordered and some people rely on that. https://github.com/MinecraftForge/MinecraftForge/issues/9774
List<TagLoader.EntryWithSource> list = new ArrayList<>();

for(TagLoader.EntryWithSource tagloader$entrywithsource : p_215980_) {
Expand Down
8 changes: 8 additions & 0 deletions patches/minecraft/net/minecraft/world/entity/Mob.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
import net.minecraft.sounds.SoundEvent;
import net.minecraft.tags.TagKey;
import net.minecraft.util.Mth;
@@ -62,7 +_,6 @@
import net.minecraft.world.item.SpawnEggItem;
import net.minecraft.world.item.SwordItem;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
-import net.minecraft.world.level.GameRules;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.LevelReader;
@@ -71,6 +_,9 @@
import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.level.pathfinder.BlockPathTypes;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
--- a/net/minecraft/world/entity/NeutralMob.java
+++ b/net/minecraft/world/entity/NeutralMob.java
@@ -8,6 +_,7 @@
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.GameRules;
import net.minecraft.world.level.Level;
+import org.bukkit.event.entity.EntityTargetEvent;

public interface NeutralMob {
String TAG_ANGER_TIME = "AngerTime";
@@ -108,7 +_,7 @@
default void stopBeingAngry() {
this.setLastHurtByMob((LivingEntity)null);
Expand All @@ -14,7 +22,7 @@
void setLastHurtByPlayer(@Nullable Player p_21680_);

- void setTarget(@Nullable LivingEntity p_21681_);
+ void setTarget(@Nullable LivingEntity p_21681_, org.bukkit.event.entity.EntityTargetEvent.TargetReason reason, boolean fireEvent); // CraftBukkit
+ boolean setTarget(@Nullable LivingEntity p_21681_, EntityTargetEvent.TargetReason reason, boolean fireEvent); // CraftBukkit

boolean canAttack(LivingEntity p_181126_);

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
--- a/net/minecraft/world/entity/ambient/Bat.java
+++ b/net/minecraft/world/entity/ambient/Bat.java
@@ -27,6 +_,7 @@
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3;
+import org.bukkit.craftbukkit.v1_20_R2.event.CraftEventFactory;

public class Bat extends AmbientCreature {
public static final float FLAP_DEGREES_PER_TICK = 74.48451F;
@@ -125,13 +_,13 @@
this.yHeadRot = (float)this.random.nextInt(360);
}

- if (this.level().getNearestPlayer(BAT_RESTING_TARGETING, this) != null) {
+ if (this.level().getNearestPlayer(Bat.BAT_RESTING_TARGETING, this) != null && CraftEventFactory.handleBatToggleSleepEvent(this, true)) { // CraftBukkit - Call BatToggleSleepEvent
this.setResting(false);
if (!flag) {
this.level().levelEvent((Player)null, 1025, blockpos, 0);
}
}
- } else {
+ } else if (CraftEventFactory.handleBatToggleSleepEvent(this, true)) { // CraftBukkit - Call BatToggleSleepEvent
this.setResting(false);
if (!flag) {
this.level().levelEvent((Player)null, 1025, blockpos, 0);
@@ -156,7 +_,7 @@
float f1 = Mth.wrapDegrees(f - this.getYRot());
this.zza = 0.5F;
this.setYRot(this.getYRot() + f1);
- if (this.random.nextInt(100) == 0 && this.level().getBlockState(blockpos1).isRedstoneConductor(this.level(), blockpos1)) {
+ if (this.random.nextInt(100) == 0 && this.level().getBlockState(blockpos1).isRedstoneConductor(this.level(), blockpos1) && CraftEventFactory.handleBatToggleSleepEvent(this, false)) { // CraftBukkit - Call BatToggleSleepEvent
this.setResting(true);
}
}
@@ -178,7 +_,7 @@
if (this.isInvulnerableTo(p_27424_)) {
return false;
} else {
- if (!this.level().isClientSide && this.isResting()) {
+ if (!this.level().isClientSide && this.isResting() && CraftEventFactory.handleBatToggleSleepEvent(this, true)) { // CraftBukkit - Call BatToggleSleepEvent
this.setResting(false);
}

Original file line number Diff line number Diff line change
@@ -1,6 +1,55 @@
--- a/net/minecraft/world/entity/animal/Animal.java
+++ b/net/minecraft/world/entity/animal/Animal.java
@@ -202,6 +_,17 @@
@@ -29,12 +_,16 @@
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.pathfinder.BlockPathTypes;
+import org.bukkit.craftbukkit.v1_20_R2.event.CraftEventFactory;
+import org.bukkit.event.entity.EntityBreedEvent;
+import org.bukkit.event.entity.EntityEnterLoveModeEvent;

public abstract class Animal extends AgeableMob {
protected static final int PARENT_AGE_AFTER_BREEDING = 6000;
private int inLove;
@Nullable
private UUID loveCause;
+ public ItemStack breedItem; // CraftBukkit - Add breedItem variable

protected Animal(EntityType<? extends Animal> p_27557_, Level p_27558_) {
super(p_27557_, p_27558_);
@@ -72,8 +_,14 @@
if (this.isInvulnerableTo(p_27567_)) {
return false;
} else {
- this.inLove = 0;
- return super.hurt(p_27567_, p_27568_);
+ // CraftBukkit start
+ boolean result = super.hurt(p_27567_, p_27568_);
+ if (result) {
+ this.inLove = 0;
+ return super.hurt(p_27567_, p_27568_);
+ }
+ return result;
+ // CraftBukkit end
}
}

@@ -156,7 +_,13 @@
}

public void setInLove(@Nullable Player p_27596_) {
- this.inLove = 600;
+ // CraftBukkit start
+ EntityEnterLoveModeEvent entityEnterLoveModeEvent = CraftEventFactory.callEntityEnterLoveModeEvent(p_27596_, this, 600);
+ if (entityEnterLoveModeEvent.isCancelled()) {
+ return;
+ }
+ this.inLove = entityEnterLoveModeEvent.getTicksInLove();
+ // CraftBukkit end
if (p_27596_ != null) {
this.loveCause = p_27596_.getUUID();
}
@@ -202,15 +_,43 @@

public void spawnChildFromBreeding(ServerLevel p_27564_, Animal p_27565_) {
AgeableMob ageablemob = this.getBreedOffspring(p_27564_, p_27565_);
Expand All @@ -18,3 +67,43 @@
if (ageablemob != null) {
ageablemob.setBaby(true);
ageablemob.moveTo(this.getX(), this.getY(), this.getZ(), 0.0F, 0.0F);
this.finalizeSpawnChildFromBreeding(p_27564_, p_27565_, ageablemob);
- p_27564_.addFreshEntityWithPassengers(ageablemob);
+ // CraftBukkit start - call EntityBreedEvent
+ ServerPlayer breeder = Optional.ofNullable(this.getLoveCause()).or(() -> {
+ return Optional.ofNullable(p_27565_.getLoveCause());
+ }).orElse(null);
+ int experience = this.getRandom().nextInt(7) + 1;
+ EntityBreedEvent entityBreedEvent = org.bukkit.craftbukkit.v1_20_R2.event.CraftEventFactory.callEntityBreedEvent(ageablemob, this, p_27565_, breeder, this.breedItem, experience);
+ if (entityBreedEvent.isCancelled()) {
+ return;
+ }
+ experience = entityBreedEvent.getExperience();
+ this.finalizeSpawnChildFromBreeding(p_27564_, p_27565_, ageablemob, experience);
+ p_27564_.addFreshEntityWithPassengers(ageablemob, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING);
+ // CraftBukkit end
}
}

public void finalizeSpawnChildFromBreeding(ServerLevel p_277963_, Animal p_277357_, @Nullable AgeableMob p_277516_) {
+ // CraftBukkit start
+ this.finalizeSpawnChildFromBreeding(p_277963_, p_277357_, p_277516_, this.getRandom().nextInt(7) + 1);
+ }
+
+ public void finalizeSpawnChildFromBreeding(ServerLevel p_277963_, Animal p_277357_, @Nullable AgeableMob p_277516_, int experience) {
Optional.ofNullable(this.getLoveCause()).or(() -> {
return Optional.ofNullable(p_277357_.getLoveCause());
}).ifPresent((p_277486_) -> {
@@ -223,7 +_,11 @@
p_277357_.resetLove();
p_277963_.broadcastEntityEvent(this, (byte)18);
if (p_277963_.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
- p_277963_.addFreshEntity(new ExperienceOrb(p_277963_, this.getX(), this.getY(), this.getZ(), this.getRandom().nextInt(7) + 1));
+ // CraftBukkit start - use event experience
+ if (experience > 0) {
+ p_277963_.addFreshEntity(new ExperienceOrb(p_277963_, this.getX(), this.getY(), this.getZ(), experience));
+ }
+ // CraftBukkit end
}

}
Loading