mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
81 lines
6.3 KiB
Diff
81 lines
6.3 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Encode42 <me@encode42.dev>
|
|
Date: Tue, 9 Feb 2021 21:23:37 -0500
|
|
Subject: [PATCH] Config to always tame in Creative
|
|
|
|
Adds a configuration option that ensures a player in Creative always tames a tameable entity.
|
|
This essentially allows Creative mode players to tame animals on their first try.
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/RunAroundLikeCrazyGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/RunAroundLikeCrazyGoal.java
|
|
index b463fdb812f1c402885f1538e1c213aea1374e5c..952b244a7423d44a0e755764e4b4b5a83ee7f42b 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/ai/goal/RunAroundLikeCrazyGoal.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/ai/goal/RunAroundLikeCrazyGoal.java
|
|
@@ -63,7 +63,7 @@ public class RunAroundLikeCrazyGoal extends Goal {
|
|
int j = this.horse.getMaxTemper();
|
|
|
|
// CraftBukkit - fire EntityTameEvent
|
|
- if (j > 0 && this.horse.getRandom().nextInt(j) < i && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this.horse, ((org.bukkit.craftbukkit.entity.CraftHumanEntity) this.horse.getBukkitEntity().getPassenger()).getHandle()).isCancelled()) {
|
|
+ if ((this.horse.level().purpurConfig.alwaysTameInCreative && ((Player) entity).getAbilities().instabuild) || (j > 0 && this.horse.getRandom().nextInt(j) < i && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this.horse, ((org.bukkit.craftbukkit.entity.CraftHumanEntity) this.horse.getBukkitEntity().getPassenger()).getHandle()).isCancelled())) { // Purpur
|
|
this.horse.tameWithName((Player) entity);
|
|
return;
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/entity/animal/Cat.java b/src/main/java/net/minecraft/world/entity/animal/Cat.java
|
|
index 1554e4a0e068e06ec121adf56421f8332132f062..7f1763b820a0c5dc69bdf6cdf14a97a283ba5916 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/animal/Cat.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/animal/Cat.java
|
|
@@ -470,7 +470,7 @@ public class Cat extends TamableAnimal implements VariantHolder<CatVariant> {
|
|
}
|
|
} else if (this.isFood(itemstack)) {
|
|
this.usePlayerItem(player, hand, itemstack);
|
|
- if (this.random.nextInt(3) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, player).isCancelled()) { // CraftBukkit
|
|
+ if ((this.level().purpurConfig.alwaysTameInCreative && player.getAbilities().instabuild) || (this.random.nextInt(3) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, player).isCancelled())) { // CraftBukkit // Purpur
|
|
this.tame(player);
|
|
this.setOrderedToSit(true);
|
|
this.level().broadcastEntityEvent(this, (byte) 7);
|
|
diff --git a/src/main/java/net/minecraft/world/entity/animal/Parrot.java b/src/main/java/net/minecraft/world/entity/animal/Parrot.java
|
|
index a2dafa064697219fcfe7824ba3ca81396063ecb2..08935a1f2c4a3f43483719686e5baab5063cdfce 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/animal/Parrot.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/animal/Parrot.java
|
|
@@ -334,7 +334,7 @@ public class Parrot extends ShoulderRidingEntity implements VariantHolder<Parrot
|
|
}
|
|
|
|
if (!this.level().isClientSide) {
|
|
- if (this.random.nextInt(10) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, player).isCancelled()) { // CraftBukkit
|
|
+ if ((this.level().purpurConfig.alwaysTameInCreative && player.getAbilities().instabuild) || (this.random.nextInt(10) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, player).isCancelled())) { // CraftBukkit // Purpur
|
|
this.tame(player);
|
|
this.level().broadcastEntityEvent(this, (byte) 7);
|
|
} else {
|
|
diff --git a/src/main/java/net/minecraft/world/entity/animal/Wolf.java b/src/main/java/net/minecraft/world/entity/animal/Wolf.java
|
|
index 0ab3e4a854fd1c5369fc734981d16fa6b844807f..b2902e01ff2e9add8258bfd0b32d000209208f52 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/animal/Wolf.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/animal/Wolf.java
|
|
@@ -543,7 +543,7 @@ public class Wolf extends TamableAnimal implements NeutralMob {
|
|
}
|
|
|
|
// CraftBukkit - added event call and isCancelled check.
|
|
- if (this.random.nextInt(3) == 0 && !CraftEventFactory.callEntityTameEvent(this, player).isCancelled()) {
|
|
+ if ((this.level().purpurConfig.alwaysTameInCreative && player.getAbilities().instabuild) || (this.random.nextInt(3) == 0 && !CraftEventFactory.callEntityTameEvent(this, player).isCancelled())) { // Purpur
|
|
this.tame(player);
|
|
this.navigation.stop();
|
|
this.setTarget((LivingEntity) null);
|
|
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
|
index cc2a4e764e49106c1d7d9bfe9536140422f75df3..7922c9f96c327dec2394d2432362c26600531a52 100644
|
|
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
|
@@ -118,6 +118,7 @@ public class PurpurWorldConfig {
|
|
}
|
|
|
|
public boolean useBetterMending = false;
|
|
+ public boolean alwaysTameInCreative = false;
|
|
public boolean boatEjectPlayersOnLand = false;
|
|
public boolean boatsDoFallDamage = false;
|
|
public boolean disableDropsOnCrammingDeath = false;
|
|
@@ -136,6 +137,7 @@ public class PurpurWorldConfig {
|
|
public int animalBreedingCooldownSeconds = 0;
|
|
private void miscGameplayMechanicsSettings() {
|
|
useBetterMending = getBoolean("gameplay-mechanics.use-better-mending", useBetterMending);
|
|
+ alwaysTameInCreative = getBoolean("gameplay-mechanics.always-tame-in-creative", alwaysTameInCreative);
|
|
boatEjectPlayersOnLand = getBoolean("gameplay-mechanics.boat.eject-players-on-land", boatEjectPlayersOnLand);
|
|
boatsDoFallDamage = getBoolean("gameplay-mechanics.boat.do-fall-damage", boatsDoFallDamage);
|
|
disableDropsOnCrammingDeath = getBoolean("gameplay-mechanics.disable-drops-on-cramming-death", disableDropsOnCrammingDeath);
|