Add setting for ocelot->cat translation in 1.13.2->1.14 (#3796)

This commit is contained in:
EnZaXD 2024-04-20 15:17:26 +02:00 committed by GitHub
parent fb434a79bd
commit 33cc21d6e6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 29 additions and 1 deletions

View File

@ -452,4 +452,11 @@ public interface ViaVersionConfig extends Config {
* @return true if enabled
*/
boolean isArmorToggleFix();
/**
* Ocelots will always be translated to cats for 1.14+ clients on 1.13 servers.
*
* @return true if enabled
*/
boolean translateOcelotToCat();
}

View File

@ -89,6 +89,7 @@ public abstract class AbstractViaConfig extends Config implements ViaVersionConf
private JsonElement resourcePack1_17PromptMessage;
private WorldIdentifiers map1_16WorldNames;
private boolean cache1_17Light;
private boolean translateOcelotToCat;
protected AbstractViaConfig(final File configFile) {
super(configFile);
@ -157,6 +158,7 @@ public abstract class AbstractViaConfig extends Config implements ViaVersionConf
worlds.getOrDefault("nether", WorldIdentifiers.NETHER_DEFAULT),
worlds.getOrDefault("end", WorldIdentifiers.END_DEFAULT));
cache1_17Light = getBoolean("cache-1_17-light", true);
translateOcelotToCat = getBoolean("translate-ocelot-to-cat", false);
}
private BlockedProtocolVersions loadBlockedProtocolVersions() {
@ -528,4 +530,9 @@ public abstract class AbstractViaConfig extends Config implements ViaVersionConf
public boolean isArmorToggleFix() {
return false;
}
@Override
public boolean translateOcelotToCat() {
return translateOcelotToCat;
}
}

View File

@ -39,7 +39,12 @@ public class MetadataRewriter1_14To1_13_2 extends EntityRewriter<ClientboundPack
public MetadataRewriter1_14To1_13_2(Protocol1_14To1_13_2 protocol) {
super(protocol);
mapTypes(EntityTypes1_13.EntityType.values(), EntityTypes1_14.class);
mapEntityType(EntityTypes1_13.EntityType.OCELOT, EntityTypes1_14.CAT);
if (Via.getConfig().translateOcelotToCat()) {
// A better solution for this would be to despawn the ocelot and spawn a cat in its place, but that would
// require a lot of data tracking and is not worth the effort.
mapEntityType(EntityTypes1_13.EntityType.OCELOT, EntityTypes1_14.CAT);
}
}
@Override
@ -159,6 +164,12 @@ public class MetadataRewriter1_14To1_13_2 extends EntityRewriter<ClientboundPack
event.cancel(); // "Has target (aggressive state)"
});
filter().type(EntityTypes1_14.OCELOT).removeIndex(17); // variant
// Ocelot is not tamable anymore
filter().type(EntityTypes1_14.OCELOT).removeIndex(16); // owner uuid
filter().type(EntityTypes1_14.OCELOT).removeIndex(15); // data
filter().handler((event, meta) -> {
EntityType type = event.entityType();
if (type.is(EntityTypes1_14.WITCH) || type.is(EntityTypes1_14.RAVAGER) || type.isOrHasParent(EntityTypes1_14.ABSTRACT_ILLAGER_BASE)) {

View File

@ -175,6 +175,9 @@ map-1_16-world-names:
nether: "minecraft:the_nether"
end: "minecraft:the_end"
#
# Ocelots will always be translated to cats for 1.14+ clients on 1.13 servers.
translate-ocelot-to-cat: false
#
#----------------------------------------------------------#
# 1.9+ CLIENTS ON 1.8 SERVERS OPTIONS #
#----------------------------------------------------------#