3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-27 08:30:09 +01:00

Add vines blockconnection to prevent unwanted climbing

Fixes #1640
Dieser Commit ist enthalten in:
KennyTV 2020-02-10 14:50:22 +01:00
Ursprung 109d5afcf5
Commit 7e164b40c7
8 geänderte Dateien mit 82 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -240,6 +240,11 @@ public class BukkitViaConfig extends Config implements ViaVersionConfig {
return getBoolean("flowerstem-when-block-above", false);
}
@Override
public boolean isVineClimbFix() {
return getBoolean("vine-climb-fix", false);
}
@Override
public boolean isSnowCollisionFix() {
return getBoolean("fix-low-snow-collision", false);

Datei anzeigen

@ -293,6 +293,11 @@ public class BungeeViaConfig extends Config implements ViaVersionConfig {
return getBoolean("flowerstem-when-block-above", false);
}
@Override
public boolean isVineClimbFix() {
return getBoolean("vine-climb-fix", false);
}
@Override
public boolean isSnowCollisionFix() {
return getBoolean("fix-low-snow-collision", false);

Datei anzeigen

@ -296,6 +296,13 @@ public interface ViaVersionConfig {
*/
boolean isStemWhenBlockAbove();
/**
* Vines not connected to any blocks will be mapped to air for 1.13+ clients to prevent them from climbing up.
*
* @return True if enabled
*/
boolean isVineClimbFix();
/**
* When activated, the 1-layer snow will be sent as 2-layer snow to 1.13+ clients to have collision.
*

Datei anzeigen

@ -252,6 +252,10 @@ public class ConnectionData {
initActions.addAll(ChorusPlantConnectionHandler.init());
initActions.add(TripwireConnectionHandler.init());
initActions.add(SnowyGrassConnectionHandler.init());
if (Via.getConfig().isVineClimbFix()) {
initActions.add(VineConnectionHandler.init());
}
for (String key : keyToId.keySet()) {
WrappedBlockData wrappedBlockData = WrappedBlockData.fromString(key);
for (ConnectorInitAction action : initActions) {

Datei anzeigen

@ -0,0 +1,48 @@
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.minecraft.BlockFace;
import us.myles.ViaVersion.api.minecraft.Position;
import java.util.HashSet;
import java.util.Set;
class VineConnectionHandler extends ConnectionHandler {
private static final Set<Integer> vines = new HashSet<>();
static ConnectionData.ConnectorInitAction init() {
final VineConnectionHandler connectionHandler = new VineConnectionHandler();
return new ConnectionData.ConnectorInitAction() {
@Override
public void check(WrappedBlockData blockData) {
if (!blockData.getMinecraftKey().equals("minecraft:vine")) return;
vines.add(blockData.getSavedBlockStateId());
ConnectionData.connectionHandlerMap.put(blockData.getSavedBlockStateId(), connectionHandler);
}
};
}
@Override
public int connect(UserConnection user, Position position, int blockState) {
if (isAttachedToBlock(user, position)) return blockState;
Position upperPos = position.getRelative(BlockFace.TOP);
int upperBlock = getBlockData(user, upperPos);
if (vines.contains(upperBlock) && isAttachedToBlock(user, upperPos)) return blockState;
// Map to air if not attached to block, and upper block is also not a vine attached to a block
return 0;
}
private boolean isAttachedToBlock(UserConnection user, Position position) {
return isAttachedToBlock(user, position, BlockFace.EAST)
|| isAttachedToBlock(user, position, BlockFace.WEST)
|| isAttachedToBlock(user, position, BlockFace.NORTH)
|| isAttachedToBlock(user, position, BlockFace.SOUTH);
}
private boolean isAttachedToBlock(UserConnection user, Position position, BlockFace blockFace) {
return ConnectionData.occludingStates.contains(getBlockData(user, position.getRelative(blockFace)));
}
}

Datei anzeigen

@ -135,7 +135,7 @@ fix-1_14-health-nan: true
# Should 1.15+ clients respawn instantly / without showing a death screen?
use-1_15-instant-respawn: false
#
# Enable serverside block-connections for 1.13+ clients
# Enable serverside block-connections for 1.13+ clients - all of the options in this section are built around this option
serverside-blockconnections: false
# Sets the method for the block connections (world for highly experimental (USE AT OWN RISK) world-level or packet for packet-level)
blockconnection-method: packet
@ -144,6 +144,8 @@ 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
# Vines that are not connected to blocks will be mapped to air, else 1.13+ would still be able to climb up on them.
vine-climb-fix: false
#
#----------------------------------------------------------#
# 1.9+ CLIENTS ON 1.8 SERVERS OPTIONS #

Datei anzeigen

@ -246,6 +246,11 @@ public class SpongeViaConfig extends Config implements ViaVersionConfig {
return getBoolean("flowerstem-when-block-above", false);
}
@Override
public boolean isVineClimbFix() {
return getBoolean("vine-climb-fix", false);
}
@Override
public boolean isSnowCollisionFix() {
return getBoolean("fix-low-snow-collision", false);

Datei anzeigen

@ -298,6 +298,11 @@ public class VelocityViaConfig extends Config implements ViaVersionConfig {
return getBoolean("flowerstem-when-block-above", false);
}
@Override
public boolean isVineClimbFix() {
return getBoolean("vine-climb-fix", false);
}
@Override
public boolean isSnowCollisionFix() {
return getBoolean("fix-low-snow-collision", false);