From 20654b0a77937d74c3372fd1f215e4ac1c7a5b30 Mon Sep 17 00:00:00 2001 From: KennyTV <28825609+KennyTV@users.noreply.github.com> Date: Wed, 9 Jan 2019 21:48:04 +0100 Subject: [PATCH] Add convenience config options Add option to send all flowerparts for 1.13+ as stems if a block is above Add option to send 1-layer snow as 2-layers for 1.13+ to fix collision --- .../bukkit/platform/BukkitViaConfig.java | 10 ++++++ .../bungee/platform/BungeeViaConfig.java | 10 ++++++ .../ViaVersion/api/ViaVersionConfig.java | 15 +++++++++ .../FlowerConnectionHandler.java | 16 +++++++--- .../data/MappingData.java | 4 +++ .../resources/assets/viaversion/config.yml | 32 +++++++++++-------- .../sponge/platform/SpongeViaConfig.java | 10 ++++++ .../velocity/platform/VelocityViaConfig.java | 10 ++++++ 8 files changed, 89 insertions(+), 18 deletions(-) diff --git a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/platform/BukkitViaConfig.java b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/platform/BukkitViaConfig.java index 056fa2abb..de078d58b 100644 --- a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/platform/BukkitViaConfig.java +++ b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/platform/BukkitViaConfig.java @@ -234,4 +234,14 @@ public class BukkitViaConfig extends Config implements ViaVersionConfig { public boolean isReduceBlockStorageMemory() { return getBoolean("reduce-blockstorage-memory", false); } + + @Override + public boolean isStemWhenBlockAbove() { + return getBoolean("flowerstem-when-block-above", false); + } + + @Override + public boolean isSnowCollisionFix() { + return getBoolean("fix-low-snow-collision", false); + } } diff --git a/bungee/src/main/java/us/myles/ViaVersion/bungee/platform/BungeeViaConfig.java b/bungee/src/main/java/us/myles/ViaVersion/bungee/platform/BungeeViaConfig.java index 99a307c0b..014bc6ea9 100644 --- a/bungee/src/main/java/us/myles/ViaVersion/bungee/platform/BungeeViaConfig.java +++ b/bungee/src/main/java/us/myles/ViaVersion/bungee/platform/BungeeViaConfig.java @@ -287,4 +287,14 @@ public class BungeeViaConfig extends Config implements ViaVersionConfig { public boolean isReduceBlockStorageMemory() { return getBoolean("reduce-blockstorage-memory", false); } + + @Override + public boolean isStemWhenBlockAbove() { + return getBoolean("flowerstem-when-block-above", false); + } + + @Override + public boolean isSnowCollisionFix() { + return getBoolean("fix-low-snow-collision", false); + } } diff --git a/common/src/main/java/us/myles/ViaVersion/api/ViaVersionConfig.java b/common/src/main/java/us/myles/ViaVersion/api/ViaVersionConfig.java index 46b3ce2fc..a228963bd 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/ViaVersionConfig.java +++ b/common/src/main/java/us/myles/ViaVersion/api/ViaVersionConfig.java @@ -287,4 +287,19 @@ public interface ViaVersionConfig { * @return True if enabled */ boolean isReduceBlockStorageMemory(); + + /** + * When activated with serverside-blockconnections, flower parts with blocks above will be sent as stems. + * Useful for lobbyservers where users can't build and those stems are used decoratively. + * + * @return True if enabled + */ + boolean isStemWhenBlockAbove(); + + /** + * When activated, the 1-layer snow will be sent as 2-layer snow to 1.13+ clients to have collision. + * + * @return True if enabled + */ + boolean isSnowCollisionFix(); } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/FlowerConnectionHandler.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/FlowerConnectionHandler.java index 8979ae95e..946a9ffc2 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/FlowerConnectionHandler.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/FlowerConnectionHandler.java @@ -1,5 +1,6 @@ package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections; +import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.minecraft.BlockFace; import us.myles.ViaVersion.api.minecraft.Position; @@ -11,10 +12,10 @@ import java.util.Set; public class FlowerConnectionHandler extends ConnectionHandler { - private static Set baseFlower = new HashSet<>(); private static Map flowers = new HashMap<>(); static void init() { + Set baseFlower = new HashSet<>(); baseFlower.add("minecraft:rose_bush"); baseFlower.add("minecraft:sunflower"); baseFlower.add("minecraft:peony"); @@ -22,9 +23,7 @@ public class FlowerConnectionHandler extends ConnectionHandler { baseFlower.add("minecraft:large_fern"); baseFlower.add("minecraft:lilac"); - FlowerConnectionHandler handler = new FlowerConnectionHandler(); - for (Map.Entry blockState : ConnectionData.keyToId.entrySet()) { WrappedBlockData data = WrappedBlockData.fromString(blockState.getKey()); if (baseFlower.contains(data.getMinecraftKey())) { @@ -40,8 +39,15 @@ public class FlowerConnectionHandler extends ConnectionHandler { @Override public int connect(UserConnection user, Position position, int blockState) { int blockBelowId = getBlockData(user, position.getRelative(BlockFace.BOTTOM)); - if (flowers.containsKey(blockBelowId) && !flowers.containsKey(getBlockData(user, position.getRelative(BlockFace.TOP)))) { - return flowers.get(blockBelowId); + if (flowers.containsKey(blockBelowId)) { + int blockAboveId = getBlockData(user, position.getRelative(BlockFace.TOP)); + if (Via.getConfig().isStemWhenBlockAbove()) { + if (blockAboveId == 0) { + return flowers.get(blockBelowId); + } + } else if (!flowers.containsKey(blockAboveId)) { + return flowers.get(blockBelowId); + } } return blockState; } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/MappingData.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/MappingData.java index 8fca9c3f3..0e9322060 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/MappingData.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/MappingData.java @@ -195,6 +195,10 @@ public class MappingData { private BlockMappingsShortArray(JsonObject mapping1_12, JsonObject mapping1_13) { Arrays.fill(oldToNew, (short) -1); mapIdentifiers(oldToNew, mapping1_12, mapping1_13); + // Map minecraft:snow[layers=1] of 1.12 to minecraft:snow[layers=2] in 1.13 + if (Via.getConfig().isSnowCollisionFix()) { + oldToNew[1248] = 3416; + } } @Override diff --git a/common/src/main/resources/assets/viaversion/config.yml b/common/src/main/resources/assets/viaversion/config.yml index 6193e28b2..dc005204c 100644 --- a/common/src/main/resources/assets/viaversion/config.yml +++ b/common/src/main/resources/assets/viaversion/config.yml @@ -114,9 +114,21 @@ team-colour-fix: true suppress-1_13-conversion-errors: false # 1.13 introduced new auto complete which can trigger "Kicked for spamming" for servers older than 1.13, the following option will disable it completely. disable-1_13-auto-complete: false +# For 1.13 clients the smallest (1 layer) snow doesn't have collision, this will send these as 2 snowlayers for 1.13+ clients to prevent them bugging through them +fix-low-snow-collision: false +# +# Enable serverside block-connections for 1.13+ clients +serverside-blockconnections: false +# Sets the method for the block connections (world for world-level or packet for packet-level) +blockconnection-method: world +# When activated, only the most important blocks are stored in the blockstorage. (fences, glass panes etc. won't connect to solid blocks) +reduce-blockstorage-memory: false +# When activated with serverside-blockconnections, flower parts with blocks above will be sent as stems +# Useful for lobbyservers where users can't build and those stems are used decoratively +flowerstem-when-block-above: false # #----------------------------------------------------------# -# 1.9 & 1.10 CLIENTS ON 1.8 SERVERS OPTIONS # +# 1.9+ CLIENTS ON 1.8 SERVERS OPTIONS # #----------------------------------------------------------# # # No collide options, these allow you to configure how collision works. @@ -126,7 +138,7 @@ prevent-collision: true auto-team: true # When enabled if certain metadata can't be read we won't tell you about it suppress-metadata-errors: false -# When enabled 1.9 & 1.10 will be able to block by using shields +# When enabled 1.9+ will be able to block by using shields shield-blocking: true # Enable player tick simulation, this fixes eating, drinking, nether portals. simulate-pt: true @@ -134,15 +146,15 @@ simulate-pt: true nms-player-ticking: true # Should we patch boss bars so they work? (Default: true, disable if you're having issues) bossbar-patch: true -# If your boss bar flickers on 1.9 & 1.10, set this to 'true'. It will keep all boss bars on 100% (not recommended) +# If your boss bar flickers on 1.9+, set this to 'true'. It will keep all boss bars on 100% (not recommended) bossbar-anti-flicker: false -# This will show the new effect indicator in the top-right corner for 1.9 & 1.10 players. +# This will show the new effect indicator in the top-right corner for 1.9+ players. use-new-effect-indicator: true -# Show the new death messages for 1.9 & 1.10 on the death screen +# Show the new death messages for 1.9+ on the death screen use-new-deathmessages: true # Should we cache our items, this will prevent server from being lagged out, however the cost is a constant task caching items item-cache: true -# Patch the Anti xray to work on 1.9 & 1.10 (If your server is 1.8) This can cost more performance, so disable it if you don't use it. +# Patch the anti xray to work on 1.9+ (If your server is 1.8) This can cost more performance, so disable it if you don't use it. anti-xray-patch: true # Should we replace extended pistons to fix 1.10.1 (Only on chunk load) replace-pistons: false @@ -151,10 +163,4 @@ replacement-piston-id: 0 # Force the string -> json transform force-json-transform: false # Minimize the cooldown animation in 1.8 servers -minimize-cooldown: true -# Enable serverside block-connections for 1.13+ clients -serverside-blockconnections: false -# Sets the method for the block connections (world for world-level or packet for packet-level) -blockconnection-method: world -# When activated, only the most important blocks are stored in the blockstorage. (fences, glass panes etc. won't connect to solid blocks) -reduce-blockstorage-memory: false \ No newline at end of file +minimize-cooldown: true \ No newline at end of file diff --git a/sponge/src/main/java/us/myles/ViaVersion/sponge/platform/SpongeViaConfig.java b/sponge/src/main/java/us/myles/ViaVersion/sponge/platform/SpongeViaConfig.java index 4fe598f51..d72a9be67 100644 --- a/sponge/src/main/java/us/myles/ViaVersion/sponge/platform/SpongeViaConfig.java +++ b/sponge/src/main/java/us/myles/ViaVersion/sponge/platform/SpongeViaConfig.java @@ -240,4 +240,14 @@ public class SpongeViaConfig extends Config implements ViaVersionConfig { public boolean isReduceBlockStorageMemory() { return getBoolean("reduce-blockstorage-memory", false); } + + @Override + public boolean isStemWhenBlockAbove() { + return getBoolean("flowerstem-when-block-above", false); + } + + @Override + public boolean isSnowCollisionFix() { + return getBoolean("fix-low-snow-collision", false); + } } diff --git a/velocity/src/main/java/us/myles/ViaVersion/velocity/platform/VelocityViaConfig.java b/velocity/src/main/java/us/myles/ViaVersion/velocity/platform/VelocityViaConfig.java index 8f3429824..cc132789f 100644 --- a/velocity/src/main/java/us/myles/ViaVersion/velocity/platform/VelocityViaConfig.java +++ b/velocity/src/main/java/us/myles/ViaVersion/velocity/platform/VelocityViaConfig.java @@ -292,4 +292,14 @@ public class VelocityViaConfig extends Config implements ViaVersionConfig { public boolean isReduceBlockStorageMemory() { return getBoolean("reduce-blockstorage-memory", false); } + + @Override + public boolean isStemWhenBlockAbove() { + return getBoolean("flowerstem-when-block-above", false); + } + + @Override + public boolean isSnowCollisionFix() { + return getBoolean("fix-low-snow-collision", false); + } }