3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-25 15:50:10 +01:00

Merge pull request #1225 from creeper123123321/master

Don't connect fences to stairs
Dieser Commit ist enthalten in:
Myles 2019-03-23 19:24:38 +00:00 committet von GitHub
Commit 73b24657f5
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
6 geänderte Dateien mit 33 neuen und 20 gelöschten Zeilen

Datei anzeigen

@ -4,6 +4,8 @@ import lombok.Getter;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.minecraft.BlockFace;
import us.myles.ViaVersion.api.minecraft.Position;
import us.myles.ViaVersion.api.protocol.ProtocolVersion;
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
import java.util.HashMap;
import java.util.HashSet;
@ -47,10 +49,11 @@ public abstract class AbstractFenceConnectionHandler extends ConnectionHandler {
protected byte getStates(UserConnection user, Position position, int blockState) {
byte states = 0;
if (connects(BlockFace.EAST, getBlockData(user, position.getRelative(BlockFace.EAST)))) states |= 1;
if (connects(BlockFace.NORTH, getBlockData(user, position.getRelative(BlockFace.NORTH)))) states |= 2;
if (connects(BlockFace.SOUTH, getBlockData(user, position.getRelative(BlockFace.SOUTH)))) states |= 4;
if (connects(BlockFace.WEST, getBlockData(user, position.getRelative(BlockFace.WEST)))) states |= 8;
boolean pre1_12 = user.get(ProtocolInfo.class).getServerProtocolVersion() < ProtocolVersion.v1_12.getId();
if (connects(BlockFace.EAST, getBlockData(user, position.getRelative(BlockFace.EAST)), pre1_12)) states |= 1;
if (connects(BlockFace.NORTH, getBlockData(user, position.getRelative(BlockFace.NORTH)), pre1_12)) states |= 2;
if (connects(BlockFace.SOUTH, getBlockData(user, position.getRelative(BlockFace.SOUTH)), pre1_12)) states |= 4;
if (connects(BlockFace.WEST, getBlockData(user, position.getRelative(BlockFace.WEST)), pre1_12)) states |= 8;
return states;
}
@ -65,7 +68,9 @@ public abstract class AbstractFenceConnectionHandler extends ConnectionHandler {
return newBlockState == null ? blockState : newBlockState;
}
protected boolean connects(BlockFace side, int blockState) {
return blockStates.contains(blockState) || blockConnections != null && ConnectionData.blockConnectionData.containsKey(blockState) && ConnectionData.blockConnectionData.get(blockState).connectsTo(blockConnections, side.opposite());
protected boolean connects(BlockFace side, int blockState, boolean pre1_12) {
return blockStates.contains(blockState) || blockConnections != null
&& ConnectionData.blockConnectionData.containsKey(blockState)
&& ConnectionData.blockConnectionData.get(blockState).connectsTo(blockConnections, side.opposite(), pre1_12);
}
}

Datei anzeigen

@ -6,14 +6,20 @@ import java.util.HashMap;
import java.util.Map;
public class BlockData {
private Map<String, Boolean[]> connectData = new HashMap<>();
private Map<String, boolean[]> connectData = new HashMap<>();
public void put(String key, Boolean[] booleans) {
public void put(String key, boolean[] booleans) {
connectData.put(key, booleans);
}
public boolean connectsTo(String blockConnection, BlockFace face) {
final Boolean[] booleans = connectData.get(blockConnection);
public boolean connectsTo(String blockConnection, BlockFace face, boolean pre1_12AbstractFence) {
boolean[] booleans = null;
if (pre1_12AbstractFence) {
booleans = connectData.get("allFalseIfStairPre1_12"); // https://minecraft.gamepedia.com/Java_Edition_1.12
}
if (booleans == null) {
booleans = connectData.get(blockConnection);
}
return booleans != null && booleans[face.ordinal()];
}
}

Datei anzeigen

@ -3,10 +3,11 @@ 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 us.myles.ViaVersion.api.protocol.ProtocolVersion;
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class ChorusPlantConnectionHandler extends AbstractFenceConnectionHandler {
private int endstone;
@ -46,13 +47,13 @@ public class ChorusPlantConnectionHandler extends AbstractFenceConnectionHandler
@Override
protected byte getStates(UserConnection user, Position position, int blockState) {
byte states = super.getStates(user, position, blockState);
if (connects(BlockFace.TOP, getBlockData(user, position.getRelative(BlockFace.TOP)))) states |= 16;
if (connects(BlockFace.BOTTOM, getBlockData(user, position.getRelative(BlockFace.BOTTOM)))) states |= 32;
if (connects(BlockFace.TOP, getBlockData(user, position.getRelative(BlockFace.TOP)), false)) states |= 16;
if (connects(BlockFace.BOTTOM, getBlockData(user, position.getRelative(BlockFace.BOTTOM)), false)) states |= 32;
return states;
}
@Override
protected boolean connects(BlockFace side, int blockState) {
protected boolean connects(BlockFace side, int blockState, boolean pre1_12) {
return getBlockStates().contains(blockState) || (side == BlockFace.BOTTOM && blockState == endstone);
}
}

Datei anzeigen

@ -212,17 +212,18 @@ public class ConnectionData {
for (Entry<String, JsonElement> type : entry.getValue().getAsJsonObject().entrySet()) {
String name = type.getKey();
JsonObject object = type.getValue().getAsJsonObject();
Boolean[] data = new Boolean[6];
boolean[] data = new boolean[6];
for (BlockFace value : BlockFace.values()) {
String face = value.toString().toLowerCase();
if (object.has(face)) {
data[value.ordinal()] = object.getAsJsonPrimitive(face).getAsBoolean();
} else {
data[value.ordinal()] = false;
}
}
blockData.put(name, data);
}
if (entry.getKey().contains("stairs")) {
blockData.put("allFalseIfStairPre1_12", new boolean[6]);
}
blockConnectionData.put(id, blockData);
}
}

Datei anzeigen

@ -83,6 +83,6 @@ public class RedstoneConnectionHandler extends ConnectionHandler {
private boolean connects(BlockFace side, int blockState) {
final BlockData blockData = ConnectionData.blockConnectionData.get(blockState);
return blockData != null && blockData.connectsTo("redstoneConnections", side.opposite());
return blockData != null && blockData.connectsTo("redstoneConnections", side.opposite(), false);
}
}

Datei anzeigen

@ -400,7 +400,7 @@ public class InventoryPackets {
newCanPlaceOn.add(new StringTag("", newValue));
}
} else {
newCanPlaceOn.add(oldTag);
newCanPlaceOn.add(new StringTag("", oldId));
}
}
tag.put(newCanPlaceOn);
@ -422,7 +422,7 @@ public class InventoryPackets {
newCanDestroy.add(new StringTag("", newValue));
}
} else {
newCanDestroy.add(oldTag);
newCanDestroy.add(new StringTag("", oldId));
}
}
tag.put(newCanDestroy);