mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-19 17:37:42 +01:00
103 lines
5.3 KiB
Diff
103 lines
5.3 KiB
Diff
From 618e343c928140ff1bae228def0b56576dbfeb1e Mon Sep 17 00:00:00 2001
|
|
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
|
Date: Thu, 19 Dec 2019 18:09:40 -0600
|
|
Subject: [PATCH] Check for PurpurClient for riding mobs
|
|
|
|
---
|
|
src/main/java/net/minecraft/server/EntityHuman.java | 1 +
|
|
src/main/java/net/minecraft/server/EntityInsentient.java | 6 ++++++
|
|
src/main/java/net/minecraft/server/PlayerConnection.java | 9 +++++++++
|
|
src/main/java/net/pl3x/purpur/PurpurConfig.java | 6 ++++++
|
|
4 files changed, 22 insertions(+)
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
|
|
index cb5f51638..9b84792ea 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityHuman.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
|
|
@@ -78,6 +78,7 @@ public abstract class EntityHuman extends EntityLiving {
|
|
// Paper start
|
|
public boolean affectsSpawning = true;
|
|
// Paper end
|
|
+ public boolean isUsingPurpurClient = false; // Purpur
|
|
|
|
// CraftBukkit start
|
|
public boolean fauxSleeping;
|
|
diff --git a/src/main/java/net/minecraft/server/EntityInsentient.java b/src/main/java/net/minecraft/server/EntityInsentient.java
|
|
index f9bbc0be4..1ec325f29 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityInsentient.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityInsentient.java
|
|
@@ -1407,6 +1407,12 @@ public abstract class EntityInsentient extends EntityLiving {
|
|
entityhuman.getBukkitEntity().sendMessage("You cannot mount that mob");
|
|
return false;
|
|
}
|
|
+ if (!entityhuman.isUsingPurpurClient) {
|
|
+ if (net.pl3x.purpur.PurpurConfig.ridablesNoClientModWarning != null && !net.pl3x.purpur.PurpurConfig.ridablesNoClientModWarning.isEmpty()) {
|
|
+ entityhuman.sendMessage(new ChatMessage(net.pl3x.purpur.PurpurConfig.ridablesNoClientModWarning));
|
|
+ }
|
|
+ return false;
|
|
+ }
|
|
return mountTo(entityhuman);
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
index a8e053b9f..6578af934 100644
|
|
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
@@ -2735,6 +2735,7 @@ public class PlayerConnection implements PacketListenerPlayIn {
|
|
// CraftBukkit start
|
|
private static final MinecraftKey CUSTOM_REGISTER = new MinecraftKey("register");
|
|
private static final MinecraftKey CUSTOM_UNREGISTER = new MinecraftKey("unregister");
|
|
+ private static final MinecraftKey PURPUR_CLIENT = new MinecraftKey("purpurclient", "protocol"); // Purpur
|
|
|
|
@Override
|
|
public void a(PacketPlayInCustomPayload packetplayincustompayload) {
|
|
@@ -2759,6 +2760,14 @@ public class PlayerConnection implements PacketListenerPlayIn {
|
|
PlayerConnection.LOGGER.error("Couldn\'t unregister custom payload", ex);
|
|
this.disconnect("Invalid payload UNREGISTER!");
|
|
}
|
|
+ // Purpur start
|
|
+ } else if (packetplayincustompayload.tag.equals(PURPUR_CLIENT)) {
|
|
+ try {
|
|
+ String protocolVersion = packetplayincustompayload.data.toString(com.google.common.base.Charsets.UTF_8);
|
|
+ player.isUsingPurpurClient = true;
|
|
+ } catch (Exception ignore) {
|
|
+ }
|
|
+ // Purpur end
|
|
} else {
|
|
try {
|
|
byte[] data = new byte[packetplayincustompayload.data.readableBytes()];
|
|
diff --git a/src/main/java/net/pl3x/purpur/PurpurConfig.java b/src/main/java/net/pl3x/purpur/PurpurConfig.java
|
|
index efdf01e98..d242fac8c 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurConfig.java
|
|
@@ -7,6 +7,7 @@ import net.minecraft.server.IRegistry;
|
|
import net.minecraft.server.MinecraftKey;
|
|
import net.minecraft.server.MinecraftServer;
|
|
import org.bukkit.Bukkit;
|
|
+import org.bukkit.ChatColor;
|
|
import org.bukkit.command.Command;
|
|
import org.bukkit.configuration.ConfigurationSection;
|
|
import org.bukkit.configuration.InvalidConfigurationException;
|
|
@@ -395,6 +396,7 @@ public class PurpurConfig {
|
|
public static boolean ridableZombie = true;
|
|
public static boolean ridableHusk = true;
|
|
public static boolean ridableZombieVillager = true;
|
|
+ public static String ridablesNoClientModWarning = "&cYou must have the PurpurClient mod to ride this mob";
|
|
private static void enableRidableMobs() {
|
|
ridableBat = getBoolean("settings.ridable.bat", ridableBat);
|
|
ridableBlaze = getBoolean("settings.ridable.blaze", ridableBlaze);
|
|
@@ -453,6 +455,10 @@ public class PurpurConfig {
|
|
ridableZombie = getBoolean("settings.ridable.zombie", ridableZombie);
|
|
ridableZombiePigman = getBoolean("settings.ridable.zombie_pigman", ridableZombiePigman);
|
|
ridableZombieVillager = getBoolean("settings.ridable.zombie_villager", ridableZombieVillager);
|
|
+ ridablesNoClientModWarning = getString("settings.ridable.no-client-mod-warning", ridablesNoClientModWarning);
|
|
+ if (ridablesNoClientModWarning != null && !ridablesNoClientModWarning.isEmpty()) {
|
|
+ ridablesNoClientModWarning = ChatColor.translateAlternateColorCodes('&', ridablesNoClientModWarning);
|
|
+ }
|
|
}
|
|
|
|
public static boolean controllableMinecarts = true;
|
|
--
|
|
2.24.0.rc1
|
|
|