Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-26 16:12:42 +01:00
Cleanup ConnectionData#update and fix doors
Dieser Commit ist enthalten in:
Ursprung
0886fdabd3
Commit
7859f5ebd6
@ -9,7 +9,12 @@ import java.util.Map;
|
|||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public enum BlockFace {
|
public enum BlockFace {
|
||||||
NORTH(0, 0, -1, EnumAxis.Z), SOUTH(0, 0, 1, EnumAxis.Z), EAST(1, 0, 0, EnumAxis.X), WEST(-1, 0, 0, EnumAxis.X), TOP(0, 1, 0, EnumAxis.Y), BOTTOM(0, -1, 0, EnumAxis.Y);
|
NORTH(0, 0, -1, EnumAxis.Z),
|
||||||
|
SOUTH(0, 0, 1, EnumAxis.Z),
|
||||||
|
EAST(1, 0, 0, EnumAxis.X),
|
||||||
|
WEST(-1, 0, 0, EnumAxis.X),
|
||||||
|
TOP(0, 1, 0, EnumAxis.Y),
|
||||||
|
BOTTOM(0, -1, 0, EnumAxis.Y);
|
||||||
|
|
||||||
private static Map<BlockFace, BlockFace> opposites = new HashMap<>();
|
private static Map<BlockFace, BlockFace> opposites = new HashMap<>();
|
||||||
|
|
||||||
|
@ -27,15 +27,15 @@ public class ConnectionData {
|
|||||||
static Set<Integer> occludingStates = new HashSet<>();
|
static Set<Integer> occludingStates = new HashSet<>();
|
||||||
|
|
||||||
public static void update(UserConnection user, Position position) {
|
public static void update(UserConnection user, Position position) {
|
||||||
for (int x = -1; x <= 1; x++) {
|
for (BlockFace face : BlockFace.values()) {
|
||||||
for (int z = -1; z <= 1; z++) {
|
Position pos = new Position(
|
||||||
for (int y = -1; y <= 1; y++) {
|
position.getX() + face.getModX(),
|
||||||
if (Math.abs(x) + Math.abs(y) + Math.abs(z) != 1) continue;
|
position.getY() + face.getModY(),
|
||||||
Position pos = new Position(position.getX() + x, position.getY() + y, position.getZ() + z);
|
position.getZ() + face.getModZ()
|
||||||
|
);
|
||||||
int blockState = Via.getManager().getProviders().get(BlockConnectionProvider.class).getBlockdata(user, pos);
|
int blockState = Via.getManager().getProviders().get(BlockConnectionProvider.class).getBlockdata(user, pos);
|
||||||
if (!connects(blockState)) continue;
|
if (!connects(blockState)) continue;
|
||||||
int newBlockState = connect(user, pos, blockState);
|
int newBlockState = connect(user, pos, blockState);
|
||||||
if (newBlockState == blockState) continue;
|
|
||||||
|
|
||||||
PacketWrapper blockUpdatePacket = new PacketWrapper(0x0B, null, user);
|
PacketWrapper blockUpdatePacket = new PacketWrapper(0x0B, null, user);
|
||||||
blockUpdatePacket.write(Type.POSITION, pos);
|
blockUpdatePacket.write(Type.POSITION, pos);
|
||||||
@ -47,8 +47,6 @@ public class ConnectionData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static BlockConnectionProvider getProvider() {
|
public static BlockConnectionProvider getProvider() {
|
||||||
return Via.getManager().getProviders().get(BlockConnectionProvider.class);
|
return Via.getManager().getProviders().get(BlockConnectionProvider.class);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren