3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-26 00:00:28 +01:00

Merge branch 'pr/987'

Dieser Commit ist enthalten in:
Myles 2018-09-23 18:43:29 +01:00
Commit 6457ff315f
7 geänderte Dateien mit 103 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -185,6 +185,11 @@ public class BukkitConfigAPI extends Config implements ViaVersionConfig {
return getString("reload-disconnect-msg", "Server reload, please rejoin!");
}
@Override
public boolean isMinimizeCooldown() {
return getBoolean("minimize-cooldown", true);
}
@Override
public URL getDefaultConfigURL() {
return BukkitConfigAPI.class.getClassLoader().getResource("assets/viaversion/config.yml");

Datei anzeigen

@ -224,6 +224,11 @@ public class BungeeConfigAPI extends Config implements ViaVersionConfig {
return getString("reload-disconnect-msg", "Server reload, please rejoin!");
}
@Override
public boolean isMinimizeCooldown() {
return getBoolean("minimize-cooldown", true);
}
/**
* What is the interval for checking servers via ping
* -1 for disabled

Datei anzeigen

@ -0,0 +1,17 @@
package us.myles.ViaVersion.api;
import lombok.AllArgsConstructor;
import lombok.Data;
@Data
@AllArgsConstructor
public class Triple<A, B, C> {
private A first;
private B second;
private C third;
@Override
public String toString() {
return "Triple{" + first + ", " + second + ", " + third + '}';
}
}

Datei anzeigen

@ -259,4 +259,11 @@ public interface ViaVersionConfig {
* @return True if enabled
*/
boolean isDisable1_13AutoComplete();
/**
* Tries to minimize cooldown animation.
*
* @return True if enabled
*/
boolean isMinimizeCooldown();
}

Datei anzeigen

@ -1,6 +1,9 @@
package us.myles.ViaVersion.protocols.protocol1_9to1_8.packets;
import com.google.common.collect.ImmutableList;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.Pair;
import us.myles.ViaVersion.api.Triple;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.minecraft.item.Item;
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
@ -17,7 +20,7 @@ import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.metadata.MetadataRewriter;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.EntityTracker;
import java.util.List;
import java.util.*;
public class EntityPackets {
public static final ValueTransformer<Byte, Short> toNewShort = new ValueTransformer<Byte, Short>(Type.SHORT) {
@ -269,9 +272,64 @@ public class EntityPackets {
}
});
/* Packets which do not have any field remapping or handlers */
// Entity Properties Packet
protocol.registerOutgoing(State.PLAY, 0x20, 0x4B, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT);
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
if (!Via.getConfig().isMinimizeCooldown()) return;
if (wrapper.get(Type.VAR_INT, 0) != wrapper.user().get(EntityTracker.class).getEntityID()) {
return;
}
int propertiesToRead = wrapper.read(Type.INT);
Map<String, Pair<Double, List<Triple<UUID, Double, Byte>>>> properties = new HashMap<>(propertiesToRead);
for (int i = 0; i < propertiesToRead; i++) {
String key = wrapper.read(Type.STRING);
Double value = wrapper.read(Type.DOUBLE);
int modifiersToRead = wrapper.read(Type.VAR_INT);
List<Triple<UUID, Double, Byte>> modifiers = new ArrayList<>(modifiersToRead);
for (int j = 0; j < modifiersToRead; j++) {
modifiers.add(
new Triple<>(
wrapper.read(Type.UUID),
wrapper.read(Type.DOUBLE), // Amount
wrapper.read(Type.BYTE) // Operation
)
);
}
properties.put(key, new Pair<>(value, modifiers));
}
protocol.registerOutgoing(State.PLAY, 0x20, 0x4B); // Entity Properties Packet
// == Why 15.9? ==
// Higher values hides the cooldown but it bugs visual animation on hand
// when removing item from hand with inventory gui
properties.put("generic.attackSpeed", new Pair<Double, List<Triple<UUID, Double, Byte>>>(15.9, ImmutableList.of( // Neutralize modifiers
new Triple<>(UUID.fromString("FA233E1C-4180-4865-B01B-BCCE9785ACA3"), 0.0, (byte) 0), // Tool and weapon modifier
new Triple<>(UUID.fromString("AF8B6E3F-3328-4C0A-AA36-5BA2BB9DBEF3"), 0.0, (byte) 2), // Dig speed
new Triple<>(UUID.fromString("55FCED67-E92A-486E-9800-B47F202C4386"), 0.0, (byte) 2) // Dig slow down
)));
wrapper.write(Type.INT, properties.size());
for (Map.Entry<String, Pair<Double, List<Triple<UUID, Double, Byte>>>> entry : properties.entrySet()) {
wrapper.write(Type.STRING, entry.getKey()); // Key
wrapper.write(Type.DOUBLE, entry.getValue().getKey()); // Value
wrapper.write(Type.VAR_INT, entry.getValue().getValue().size());
for (Triple<UUID, Double, Byte> modifier : entry.getValue().getValue()) {
wrapper.write(Type.UUID, modifier.getFirst());
wrapper.write(Type.DOUBLE, modifier.getSecond()); // Amount
wrapper.write(Type.BYTE, modifier.getThird()); // Operation
}
}
}
});
}
});
/* Packets which do not have any field remapping or handlers */
protocol.registerOutgoing(State.PLAY, 0x1A, 0x1B); // Entity Status Packet
protocol.registerOutgoing(State.PLAY, 0x16, 0x27); // Entity Look Packet

Datei anzeigen

@ -127,4 +127,6 @@ replace-pistons: false
# What id should we replace with, default is air. (careful of players getting stuck standing on them)
replacement-piston-id: 0
# Force the string -> json transform
force-json-transform: false
force-json-transform: false
# Minimize the cooldown animation in 1.8 servers
minimize-cooldown: true

Datei anzeigen

@ -206,6 +206,11 @@ public class SpongeConfigAPI extends Config implements ViaVersionConfig {
return getString("reload-disconnect-msg", "Server reload, please rejoin!");
}
@Override
public boolean isMinimizeCooldown() {
return getBoolean("minimize-cooldown", true);
}
@Override
public boolean is1_13TeamColourFix() {
return getBoolean("team-colour-fix", true);