Compare commits

...
8 Commits
Author SHA1 Message Date
FlorianMichael 3e261824ef 4.0.1 Release 2024-06-27 18:13:39 +02:00
FlorianMichael 43c3bb11dc Skip metadata of entities which aren't spawned (yet) 2024-06-27 15:52:00 +02:00
FlorianMichael f57ac05bd4 Add setting for levitation emulation, cleanup code 2024-06-27 02:17:59 +02:00
FlorianMichael a3c623c202 Slightly improve wording in config.yml 2024-06-22 00:56:42 +02:00
FlorianMichael 481315f1e6 Cleanup code 2024-06-22 00:55:50 +02:00
FlorianMichael 21e50421e5 Rename Gradle convention plugin 2024-06-21 11:28:07 +02:00
FlorianMichael 233d52281b Add getter/setter for CooldownStorage#visualizationFactory
Allows servers to override the existing visualization factory with their own ones
2024-06-21 11:25:25 +02:00
FlorianMichael 6807a02de7 Bump version to 4.0.1-SNAPSHOT 2024-06-21 11:23:57 +02:00
15 changed files with 55 additions and 29 deletions

No files matched your search

+1 -1
View File
@@ -1,5 +1,5 @@
plugins {
id "com.viaversion.java-conventions"
id "vr.java-conventions"
}
dependencies {
+1 -1
View File
@@ -1,5 +1,5 @@
plugins {
id "com.viaversion.java-conventions"
id "vr.java-conventions"
}
plugins {
@@ -39,6 +39,7 @@ public class ViaRewindConfig extends Config implements com.viaversion.viarewind.
private String worldBorderParticle;
private boolean enableOffhand;
private String offhandCommand;
private boolean emulateLevitationEffect;
public ViaRewindConfig(File configFile, Logger logger) {
super(configFile, logger);
@@ -61,6 +62,7 @@ public class ViaRewindConfig extends Config implements com.viaversion.viarewind.
worldBorderParticle = getString("world-border-particle", "fireworksSpark");
enableOffhand = getBoolean("enable-offhand", true);
offhandCommand = getString("offhand-command", "/offhand");
emulateLevitationEffect = getBoolean("emulate-levitation-effect", true);
}
@Override
@@ -113,6 +115,11 @@ public class ViaRewindConfig extends Config implements com.viaversion.viarewind.
return offhandCommand;
}
@Override
public boolean emulateLevitationEffect() {
return emulateLevitationEffect;
}
@Override
public URL getDefaultConfigURL() {
return getClass().getClassLoader().getResource("assets/viarewind/config.yml");
@@ -103,4 +103,11 @@ public interface ViaRewindConfig extends Config {
* @return the offhand command
*/
String getOffhandCommand();
/**
* If enabled, 1.8 players on 1.9+ servers will also experience the levitation effect by sending velocity packets.
*
* @return true if enabled
*/
boolean emulateLevitationEffect();
}
@@ -174,12 +174,8 @@ public enum EntityDataIndex1_7_6_10 {
}
private static Optional<EntityDataIndex1_7_6_10> getIndex(EntityType type, int index) {
Pair<EntityType, Integer> pair = new Pair<>(type, index);
if (ENTITY_DATA_REWRITES.containsKey(pair)) {
return Optional.of(ENTITY_DATA_REWRITES.get(pair));
}
return Optional.empty();
final Pair<EntityType, Integer> pair = new Pair<>(type, index);
return Optional.ofNullable(ENTITY_DATA_REWRITES.get(pair));
}
public EntityTypes1_8.EntityType getClazz() {
@@ -203,6 +199,10 @@ public enum EntityDataIndex1_7_6_10 {
}
public static EntityDataIndex1_7_6_10 searchIndex(EntityType type, int index) {
if (type == null) {
// Plugins sending metadata before an entity is spawned, causing exceptions while the game ignores them.
return null;
}
EntityType currentType = type;
do {
Optional<EntityDataIndex1_7_6_10> optMeta = getIndex(currentType, index);
@@ -57,7 +57,6 @@ public interface CooldownVisualization {
case BOSS_BAR -> BossBarVisualization::new;
case ACTION_BAR -> ActionBarVisualization::new;
case DISABLED -> DISABLED;
default -> throw new IllegalArgumentException("Unexpected: " + indicator);
};
}
@@ -37,14 +37,14 @@ public class EntityDataIndex1_8 {
private static Optional<EntityDataIndex1_9> getIndex(final EntityType type, final int index) {
final Pair<EntityType, Integer> pair = new Pair<>(type, index);
if (ENTITY_DATA_REWRITES.containsKey(pair)) {
return Optional.of(ENTITY_DATA_REWRITES.get(pair));
} else {
return Optional.empty();
}
return Optional.ofNullable(ENTITY_DATA_REWRITES.get(pair));
}
public static EntityDataIndex1_9 searchIndex(final EntityType type, final int index) {
if (type == null) {
// Plugins sending metadata before an entity is spawned, causing exceptions while the game ignores them.
return null;
}
EntityType currentType = type;
do {
final Optional<EntityDataIndex1_9> optMeta = getIndex(currentType, index);
@@ -17,7 +17,6 @@
*/
package com.viaversion.viarewind.protocol.v1_9to1_8.rewriter;
import com.viaversion.viarewind.ViaRewind;
import com.viaversion.viarewind.api.minecraft.math.RelativeMoveUtil;
import com.viaversion.viarewind.api.rewriter.VREntityRewriter;
import com.viaversion.viarewind.protocol.v1_9to1_8.Protocol1_9To1_8;
@@ -26,7 +25,6 @@ import com.viaversion.viarewind.protocol.v1_9to1_8.storage.CooldownStorage;
import com.viaversion.viarewind.protocol.v1_9to1_8.storage.EntityTracker1_9;
import com.viaversion.viarewind.protocol.v1_9to1_8.storage.LevitationStorage;
import com.viaversion.viarewind.protocol.v1_9to1_8.storage.PlayerPositionTracker;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.minecraft.BlockPosition;
import com.viaversion.viaversion.api.minecraft.EulerAngle;
import com.viaversion.viaversion.api.minecraft.Vector;
@@ -52,7 +50,6 @@ import com.viaversion.viaversion.util.Pair;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.logging.Level;
public class EntityPacketRewriter1_9 extends VREntityRewriter<ClientboundPackets1_9, Protocol1_9To1_8> {
@@ -28,11 +28,12 @@ import java.util.logging.Level;
public class CooldownStorage implements StorableObject {
private double attackSpeed = 4.0;
private long lastHit = 0;
private CooldownVisualization.Factory visualizationFactory = CooldownVisualization.Factory.fromConfiguration();
private CooldownVisualization current;
private double attackSpeed = 4.0;
private long lastHit = 0;
public void tick(final UserConnection connection) {
if (!hasCooldown()) {
endCurrentVisualization();
@@ -110,4 +111,12 @@ public class CooldownStorage implements StorableObject {
public void setLastHit(long lastHit) {
this.lastHit = lastHit;
}
public CooldownVisualization.Factory getVisualizationFactory() {
return visualizationFactory;
}
public void setVisualizationFactory(CooldownVisualization.Factory visualizationFactory) {
this.visualizationFactory = visualizationFactory;
}
}
@@ -32,6 +32,9 @@ public class LevitationUpdateTask implements Runnable {
@Override
public void run() {
if (!ViaRewind.getConfig().emulateLevitationEffect()) {
return;
}
for (UserConnection connection : Via.getManager().getConnectionManager().getConnections()) {
final LevitationStorage levitation = connection.get(LevitationStorage.class);
if (!levitation.isActive()) {
@@ -3,7 +3,8 @@
# Specifies how 1.8.x clients should see the cooldown indicator
# You can choose between TITLE, ACTION_BAR, BOSS_BAR and DISABLED
# ONLY DISABLE IF YOU HAVE 1.9 COOLDOWN DISABLED ON YOUR SERVER
# 1.8 PLAYERS MAY ASK WHY PVP IS NOT WORKING OTHERWISE
# 1.8 PLAYERS MAY ASK WHY PVP IS NOT WORKING OTHERWISE.
# REQUIRES A SERVER RESTART TO TAKE EFFECT
cooldown-indicator: 'TITLE'
#
# Replaces Adventure mode with Survival mode for 1.7.x clients
@@ -11,14 +12,14 @@ cooldown-indicator: 'TITLE'
# or 'CanPlaceOn' flags on items
replace-adventure: false
#
# Whether 1.9 particles should be replaced by similar ones in
# Whether similar ones should replace 1.9 particles in
# 1.8 and lower
replace-particles: false
#
# Max amount of pages for written books before a client gets kicked
# Max number of pages for written books before a client gets kicked
max-book-pages: 100
#
# Max amount of characters in the json (!) string of a book page before a client gets kicked
# Max number of characters in the json (!) string of a book page before a client gets kicked
max-book-page-length: 5000
#
# Whether to emulate the 1.8+ world border for 1.7.x clients
@@ -28,11 +29,14 @@ emulate-world-border: true
always-show-original-mob-name: true
#
# The particle to show the world border for the 1.8+ world border for 1.7.x clients
# see https://wiki.vg/index.php?title=Protocol&oldid=7368#Particle_2
# sees https://wiki.vg/index.php?title=Protocol&oldid=7368#Particle_2
world-border-particle: 'fireworksSpark'
#
# If enabled, 1.8 players on 1.9+ servers can use /offhand to switch items between their main hand and offhand.
enable-offhand: true
#
# Allows to define the offhand command
offhand-command: '/offhand'
# Allows defining the offhand command
offhand-command: '/offhand'
#
# If enabled, 1.8 players on 1.9+ servers will also experience the levitation effect by sending velocity packets.
emulate-levitation-effect: true
+1 -1
View File
@@ -1,5 +1,5 @@
plugins {
id "com.viaversion.java-conventions"
id "vr.java-conventions"
}
dependencies {
+1 -1
View File
@@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx8G
org.gradle.parallel=true
# project
maven_version=4.0.0
maven_version=4.0.1
maven_group=com.viaversion
# libraries
+1 -1
View File
@@ -1,5 +1,5 @@
plugins {
id "com.viaversion.java-conventions"
id "vr.java-conventions"
}
dependencies {