Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-03 14:50:30 +01:00
Merge pull request #1225 from creeper123123321/master
Don't connect fences to stairs
Dieser Commit ist enthalten in:
Commit
73b24657f5
@ -4,6 +4,8 @@ import lombok.Getter;
|
|||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
import us.myles.ViaVersion.api.minecraft.BlockFace;
|
import us.myles.ViaVersion.api.minecraft.BlockFace;
|
||||||
import us.myles.ViaVersion.api.minecraft.Position;
|
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.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -47,10 +49,11 @@ public abstract class AbstractFenceConnectionHandler extends ConnectionHandler {
|
|||||||
|
|
||||||
protected byte getStates(UserConnection user, Position position, int blockState) {
|
protected byte getStates(UserConnection user, Position position, int blockState) {
|
||||||
byte states = 0;
|
byte states = 0;
|
||||||
if (connects(BlockFace.EAST, getBlockData(user, position.getRelative(BlockFace.EAST)))) states |= 1;
|
boolean pre1_12 = user.get(ProtocolInfo.class).getServerProtocolVersion() < ProtocolVersion.v1_12.getId();
|
||||||
if (connects(BlockFace.NORTH, getBlockData(user, position.getRelative(BlockFace.NORTH)))) states |= 2;
|
if (connects(BlockFace.EAST, getBlockData(user, position.getRelative(BlockFace.EAST)), pre1_12)) states |= 1;
|
||||||
if (connects(BlockFace.SOUTH, getBlockData(user, position.getRelative(BlockFace.SOUTH)))) states |= 4;
|
if (connects(BlockFace.NORTH, getBlockData(user, position.getRelative(BlockFace.NORTH)), pre1_12)) states |= 2;
|
||||||
if (connects(BlockFace.WEST, getBlockData(user, position.getRelative(BlockFace.WEST)))) states |= 8;
|
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;
|
return states;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,7 +68,9 @@ public abstract class AbstractFenceConnectionHandler extends ConnectionHandler {
|
|||||||
return newBlockState == null ? blockState : newBlockState;
|
return newBlockState == null ? blockState : newBlockState;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean connects(BlockFace side, int blockState) {
|
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());
|
return blockStates.contains(blockState) || blockConnections != null
|
||||||
|
&& ConnectionData.blockConnectionData.containsKey(blockState)
|
||||||
|
&& ConnectionData.blockConnectionData.get(blockState).connectsTo(blockConnections, side.opposite(), pre1_12);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,14 +6,20 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class BlockData {
|
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);
|
connectData.put(key, booleans);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean connectsTo(String blockConnection, BlockFace face) {
|
public boolean connectsTo(String blockConnection, BlockFace face, boolean pre1_12AbstractFence) {
|
||||||
final Boolean[] booleans = connectData.get(blockConnection);
|
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()];
|
return booleans != null && booleans[face.ordinal()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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.data.UserConnection;
|
||||||
import us.myles.ViaVersion.api.minecraft.BlockFace;
|
import us.myles.ViaVersion.api.minecraft.BlockFace;
|
||||||
import us.myles.ViaVersion.api.minecraft.Position;
|
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.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class ChorusPlantConnectionHandler extends AbstractFenceConnectionHandler {
|
public class ChorusPlantConnectionHandler extends AbstractFenceConnectionHandler {
|
||||||
private int endstone;
|
private int endstone;
|
||||||
@ -46,13 +47,13 @@ public class ChorusPlantConnectionHandler extends AbstractFenceConnectionHandler
|
|||||||
@Override
|
@Override
|
||||||
protected byte getStates(UserConnection user, Position position, int blockState) {
|
protected byte getStates(UserConnection user, Position position, int blockState) {
|
||||||
byte states = super.getStates(user, position, blockState);
|
byte states = super.getStates(user, position, blockState);
|
||||||
if (connects(BlockFace.TOP, getBlockData(user, position.getRelative(BlockFace.TOP)))) states |= 16;
|
if (connects(BlockFace.TOP, getBlockData(user, position.getRelative(BlockFace.TOP)), false)) states |= 16;
|
||||||
if (connects(BlockFace.BOTTOM, getBlockData(user, position.getRelative(BlockFace.BOTTOM)))) states |= 32;
|
if (connects(BlockFace.BOTTOM, getBlockData(user, position.getRelative(BlockFace.BOTTOM)), false)) states |= 32;
|
||||||
return states;
|
return states;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
return getBlockStates().contains(blockState) || (side == BlockFace.BOTTOM && blockState == endstone);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -212,17 +212,18 @@ public class ConnectionData {
|
|||||||
for (Entry<String, JsonElement> type : entry.getValue().getAsJsonObject().entrySet()) {
|
for (Entry<String, JsonElement> type : entry.getValue().getAsJsonObject().entrySet()) {
|
||||||
String name = type.getKey();
|
String name = type.getKey();
|
||||||
JsonObject object = type.getValue().getAsJsonObject();
|
JsonObject object = type.getValue().getAsJsonObject();
|
||||||
Boolean[] data = new Boolean[6];
|
boolean[] data = new boolean[6];
|
||||||
for (BlockFace value : BlockFace.values()) {
|
for (BlockFace value : BlockFace.values()) {
|
||||||
String face = value.toString().toLowerCase();
|
String face = value.toString().toLowerCase();
|
||||||
if (object.has(face)) {
|
if (object.has(face)) {
|
||||||
data[value.ordinal()] = object.getAsJsonPrimitive(face).getAsBoolean();
|
data[value.ordinal()] = object.getAsJsonPrimitive(face).getAsBoolean();
|
||||||
} else {
|
|
||||||
data[value.ordinal()] = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
blockData.put(name, data);
|
blockData.put(name, data);
|
||||||
}
|
}
|
||||||
|
if (entry.getKey().contains("stairs")) {
|
||||||
|
blockData.put("allFalseIfStairPre1_12", new boolean[6]);
|
||||||
|
}
|
||||||
blockConnectionData.put(id, blockData);
|
blockConnectionData.put(id, blockData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,6 +83,6 @@ public class RedstoneConnectionHandler extends ConnectionHandler {
|
|||||||
|
|
||||||
private boolean connects(BlockFace side, int blockState) {
|
private boolean connects(BlockFace side, int blockState) {
|
||||||
final BlockData blockData = ConnectionData.blockConnectionData.get(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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -400,7 +400,7 @@ public class InventoryPackets {
|
|||||||
newCanPlaceOn.add(new StringTag("", newValue));
|
newCanPlaceOn.add(new StringTag("", newValue));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
newCanPlaceOn.add(oldTag);
|
newCanPlaceOn.add(new StringTag("", oldId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tag.put(newCanPlaceOn);
|
tag.put(newCanPlaceOn);
|
||||||
@ -422,7 +422,7 @@ public class InventoryPackets {
|
|||||||
newCanDestroy.add(new StringTag("", newValue));
|
newCanDestroy.add(new StringTag("", newValue));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
newCanDestroy.add(oldTag);
|
newCanDestroy.add(new StringTag("", oldId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tag.put(newCanDestroy);
|
tag.put(newCanDestroy);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren