Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-24 15:20:15 +01:00
Merge branch 'master' into dev
Dieser Commit ist enthalten in:
Commit
7e8e3fef61
@ -1,7 +1,7 @@
|
||||
sudo: false
|
||||
|
||||
language: java
|
||||
jdk:
|
||||
jdk:
|
||||
- oraclejdk8
|
||||
- openjdk11
|
||||
|
||||
|
@ -9,26 +9,27 @@ import java.util.Map;
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
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<>();
|
||||
static {
|
||||
opposites.put(BlockFace.NORTH, BlockFace.SOUTH);
|
||||
opposites.put(BlockFace.SOUTH, BlockFace.NORTH);
|
||||
opposites.put(BlockFace.EAST, BlockFace.WEST);
|
||||
opposites.put(BlockFace.WEST, BlockFace.EAST);
|
||||
opposites.put(BlockFace.TOP, BlockFace.BOTTOM);
|
||||
opposites.put(BlockFace.BOTTOM, BlockFace.TOP);
|
||||
}
|
||||
private static Map<BlockFace, BlockFace> opposites = new HashMap<>();
|
||||
|
||||
private int modX, modY, modZ;
|
||||
private EnumAxis axis;
|
||||
static {
|
||||
opposites.put(BlockFace.NORTH, BlockFace.SOUTH);
|
||||
opposites.put(BlockFace.SOUTH, BlockFace.NORTH);
|
||||
opposites.put(BlockFace.EAST, BlockFace.WEST);
|
||||
opposites.put(BlockFace.WEST, BlockFace.EAST);
|
||||
opposites.put(BlockFace.TOP, BlockFace.BOTTOM);
|
||||
opposites.put(BlockFace.BOTTOM, BlockFace.TOP);
|
||||
}
|
||||
|
||||
public BlockFace opposite() {
|
||||
return opposites.get(this);
|
||||
}
|
||||
private int modX, modY, modZ;
|
||||
private EnumAxis axis;
|
||||
|
||||
public enum EnumAxis {
|
||||
X, Y, Z;
|
||||
}
|
||||
public BlockFace opposite() {
|
||||
return opposites.get(this);
|
||||
}
|
||||
|
||||
public enum EnumAxis {
|
||||
X, Y, Z;
|
||||
}
|
||||
}
|
||||
|
@ -9,13 +9,13 @@ import java.util.List;
|
||||
@AllArgsConstructor
|
||||
@Data
|
||||
public class BaseChunk implements Chunk {
|
||||
protected int x;
|
||||
protected int z;
|
||||
protected boolean groundUp;
|
||||
protected int bitmask;
|
||||
protected ChunkSection[] sections;
|
||||
protected int[] biomeData;
|
||||
protected List<CompoundTag> blockEntities;
|
||||
protected int x;
|
||||
protected int z;
|
||||
protected boolean groundUp;
|
||||
protected int bitmask;
|
||||
protected ChunkSection[] sections;
|
||||
protected int[] biomeData;
|
||||
protected List<CompoundTag> blockEntities;
|
||||
|
||||
@Override
|
||||
public boolean isBiomeData() {
|
||||
|
@ -98,22 +98,22 @@ public class ChunkSection {
|
||||
}
|
||||
|
||||
public void replacePaletteEntry(int oldId, int newId) {
|
||||
Integer index = inversePalette.remove(oldId);
|
||||
if (index == null) return;
|
||||
inversePalette.put(newId, index);
|
||||
for (int i = 0; i < palette.size(); i++) {
|
||||
if (palette.get(i) == oldId) palette.set(i, newId);
|
||||
}
|
||||
Integer index = inversePalette.remove(oldId);
|
||||
if (index == null) return;
|
||||
inversePalette.put(newId, index);
|
||||
for (int i = 0; i < palette.size(); i++) {
|
||||
if (palette.get(i) == oldId) palette.set(i, newId);
|
||||
}
|
||||
}
|
||||
|
||||
public void addPaletteEntry(int id) {
|
||||
inversePalette.put(id, palette.size());
|
||||
palette.add(id);
|
||||
inversePalette.put(id, palette.size());
|
||||
palette.add(id);
|
||||
}
|
||||
|
||||
public void clearPalette() {
|
||||
palette.clear();
|
||||
inversePalette.clear();
|
||||
palette.clear();
|
||||
inversePalette.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -124,14 +124,14 @@ public class ChunkSection {
|
||||
* @param id The raw or flat id of the block
|
||||
*/
|
||||
public void setFlatBlock(int idx, int id) {
|
||||
Integer index = inversePalette.get(id);
|
||||
if (index == null) {
|
||||
index = palette.size();
|
||||
palette.add(id);
|
||||
inversePalette.put(id, index);
|
||||
}
|
||||
Integer index = inversePalette.get(id);
|
||||
if (index == null) {
|
||||
index = palette.size();
|
||||
palette.add(id);
|
||||
inversePalette.put(id, index);
|
||||
}
|
||||
|
||||
blocks[idx] = index;
|
||||
blocks[idx] = index;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -22,13 +22,13 @@ public class Protocol1_13_2To1_13_1 extends Protocol {
|
||||
WorldPackets.register(this);
|
||||
EntityPackets.register(this);
|
||||
|
||||
//Edit Book
|
||||
registerIncoming(State.PLAY, 0x0B, 0x0B, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.FLAT_VAR_INT_ITEM, Type.FLAT_ITEM);
|
||||
}
|
||||
});
|
||||
//Edit Book
|
||||
registerIncoming(State.PLAY, 0x0B, 0x0B, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.FLAT_VAR_INT_ITEM, Type.FLAT_ITEM);
|
||||
}
|
||||
});
|
||||
|
||||
// Advancements
|
||||
registerOutgoing(State.PLAY, 0x51, 0x51, new PacketRemapper() {
|
||||
|
@ -16,7 +16,7 @@ public abstract class AbstractFenceConnectionHandler extends ConnectionHandler {
|
||||
private Set<Integer> blockStates = new HashSet<>();
|
||||
private Map<Byte, Integer> connectedBlockStates = new HashMap<>();
|
||||
|
||||
public AbstractFenceConnectionHandler(String blockConnections, String key){
|
||||
public AbstractFenceConnectionHandler(String blockConnections, String key) {
|
||||
this.blockConnections = blockConnections;
|
||||
|
||||
for (Map.Entry<String, Integer> blockState : ConnectionData.keyToId.entrySet()) {
|
||||
|
@ -8,11 +8,11 @@ import java.util.Map;
|
||||
public class BlockData {
|
||||
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){
|
||||
public boolean connectsTo(String blockConnection, BlockFace face) {
|
||||
final Boolean[] booleans = connectData.get(blockConnection);
|
||||
return booleans != null && booleans[face.ordinal()];
|
||||
}
|
||||
|
@ -10,52 +10,52 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
class ChestConnectionHandler extends ConnectionHandler {
|
||||
private static Map<Integer, BlockFace> chestFacings = new HashMap<>();
|
||||
private static Map<Byte, Integer> connectedStates = new HashMap<>();
|
||||
private static Set<Integer> trappedChests = new HashSet<>();
|
||||
private static Map<Integer, BlockFace> chestFacings = new HashMap<>();
|
||||
private static Map<Byte, Integer> connectedStates = new HashMap<>();
|
||||
private static Set<Integer> trappedChests = new HashSet<>();
|
||||
|
||||
static void init() {
|
||||
ChestConnectionHandler connectionHandler = new ChestConnectionHandler();
|
||||
for (Map.Entry<String, Integer> blockState : ConnectionData.keyToId.entrySet()) {
|
||||
String key = blockState.getKey().split("\\[")[0];
|
||||
if (!key.equals("minecraft:chest") && !key.equals("minecraft:trapped_chest")) continue;
|
||||
WrappedBlockData blockData = WrappedBlockData.fromString(blockState.getKey());
|
||||
if (blockData.getValue("waterlogged").equals("true")) continue;
|
||||
chestFacings.put(blockState.getValue(), BlockFace.valueOf(blockData.getValue("facing").toUpperCase()));
|
||||
if (key.equalsIgnoreCase("minecraft:trapped_chest")) trappedChests.add(blockState.getValue());
|
||||
connectedStates.put(getStates(blockData), blockState.getValue());
|
||||
ConnectionData.connectionHandlerMap.put(blockState.getValue(), connectionHandler);
|
||||
}
|
||||
}
|
||||
static void init() {
|
||||
ChestConnectionHandler connectionHandler = new ChestConnectionHandler();
|
||||
for (Map.Entry<String, Integer> blockState : ConnectionData.keyToId.entrySet()) {
|
||||
String key = blockState.getKey().split("\\[")[0];
|
||||
if (!key.equals("minecraft:chest") && !key.equals("minecraft:trapped_chest")) continue;
|
||||
WrappedBlockData blockData = WrappedBlockData.fromString(blockState.getKey());
|
||||
if (blockData.getValue("waterlogged").equals("true")) continue;
|
||||
chestFacings.put(blockState.getValue(), BlockFace.valueOf(blockData.getValue("facing").toUpperCase()));
|
||||
if (key.equalsIgnoreCase("minecraft:trapped_chest")) trappedChests.add(blockState.getValue());
|
||||
connectedStates.put(getStates(blockData), blockState.getValue());
|
||||
ConnectionData.connectionHandlerMap.put(blockState.getValue(), connectionHandler);
|
||||
}
|
||||
}
|
||||
|
||||
private static Byte getStates(WrappedBlockData blockData) {
|
||||
byte states = 0;
|
||||
String type = blockData.getValue("type");
|
||||
if (type.equals("left")) states |= 1;
|
||||
if (type.equals("right")) states |= 2;
|
||||
states |= (BlockFace.valueOf(blockData.getValue("facing").toUpperCase()).ordinal() << 2);
|
||||
if (blockData.getMinecraftKey().equals("minecraft:trapped_chest")) states |= 16;
|
||||
return states;
|
||||
}
|
||||
private static Byte getStates(WrappedBlockData blockData) {
|
||||
byte states = 0;
|
||||
String type = blockData.getValue("type");
|
||||
if (type.equals("left")) states |= 1;
|
||||
if (type.equals("right")) states |= 2;
|
||||
states |= (BlockFace.valueOf(blockData.getValue("facing").toUpperCase()).ordinal() << 2);
|
||||
if (blockData.getMinecraftKey().equals("minecraft:trapped_chest")) states |= 16;
|
||||
return states;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int connect(UserConnection user, Position position, int blockState) {
|
||||
BlockFace facing = chestFacings.get(blockState);
|
||||
byte states = 0;
|
||||
states |= (facing.ordinal() << 2);
|
||||
boolean trapped = trappedChests.contains(blockState);
|
||||
if (trapped) states |= 16;
|
||||
int relative;
|
||||
if (chestFacings.containsKey(relative = getBlockData(user, position.getRelative(BlockFace.NORTH))) && trapped == trappedChests.contains(relative)) {
|
||||
states |= facing == BlockFace.WEST ? 1 : 2;
|
||||
} else if (chestFacings.containsKey(relative = getBlockData(user, position.getRelative(BlockFace.SOUTH))) && trapped == trappedChests.contains(relative)) {
|
||||
states |= facing == BlockFace.EAST ? 1 : 2;
|
||||
} else if (chestFacings.containsKey(relative = getBlockData(user, position.getRelative(BlockFace.WEST))) && trapped == trappedChests.contains(relative)) {
|
||||
states |= facing == BlockFace.NORTH ? 2 : 1;
|
||||
} else if (chestFacings.containsKey(relative = getBlockData(user, position.getRelative(BlockFace.EAST))) && trapped == trappedChests.contains(relative)) {
|
||||
states |= facing == BlockFace.SOUTH ? 2 : 1;
|
||||
}
|
||||
Integer newBlockState = connectedStates.get(states);
|
||||
return newBlockState == null ? blockState : newBlockState;
|
||||
}
|
||||
@Override
|
||||
public int connect(UserConnection user, Position position, int blockState) {
|
||||
BlockFace facing = chestFacings.get(blockState);
|
||||
byte states = 0;
|
||||
states |= (facing.ordinal() << 2);
|
||||
boolean trapped = trappedChests.contains(blockState);
|
||||
if (trapped) states |= 16;
|
||||
int relative;
|
||||
if (chestFacings.containsKey(relative = getBlockData(user, position.getRelative(BlockFace.NORTH))) && trapped == trappedChests.contains(relative)) {
|
||||
states |= facing == BlockFace.WEST ? 1 : 2;
|
||||
} else if (chestFacings.containsKey(relative = getBlockData(user, position.getRelative(BlockFace.SOUTH))) && trapped == trappedChests.contains(relative)) {
|
||||
states |= facing == BlockFace.EAST ? 1 : 2;
|
||||
} else if (chestFacings.containsKey(relative = getBlockData(user, position.getRelative(BlockFace.WEST))) && trapped == trappedChests.contains(relative)) {
|
||||
states |= facing == BlockFace.NORTH ? 2 : 1;
|
||||
} else if (chestFacings.containsKey(relative = getBlockData(user, position.getRelative(BlockFace.EAST))) && trapped == trappedChests.contains(relative)) {
|
||||
states |= facing == BlockFace.SOUTH ? 2 : 1;
|
||||
}
|
||||
Integer newBlockState = connectedStates.get(states);
|
||||
return newBlockState == null ? blockState : newBlockState;
|
||||
}
|
||||
}
|
||||
|
@ -8,12 +8,12 @@ import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.provi
|
||||
public abstract class ConnectionHandler {
|
||||
public abstract int connect(UserConnection user, Position position, int blockState);
|
||||
|
||||
public int getBlockData(UserConnection user, Position position) {
|
||||
return Via.getManager().getProviders().get(BlockConnectionProvider.class).getBlockdata(user, position);
|
||||
public int getBlockData(UserConnection user, Position position) {
|
||||
return Via.getManager().getProviders().get(BlockConnectionProvider.class).getBlockdata(user, position);
|
||||
}
|
||||
|
||||
public boolean canConnect(int id) {
|
||||
ConnectionHandler handler = ConnectionData.connectionHandlerMap.get(id);
|
||||
return handler != null && handler == this;
|
||||
ConnectionHandler handler = ConnectionData.connectionHandlerMap.get(id);
|
||||
return handler != null && handler == this;
|
||||
}
|
||||
}
|
||||
|
@ -39,11 +39,15 @@ public class RedstoneConnectionHandler extends ConnectionHandler {
|
||||
}
|
||||
|
||||
private static int getState(String value) {
|
||||
switch (value){
|
||||
case "none": return 0;
|
||||
case "side" : return 1;
|
||||
case "up" : return 2;
|
||||
default: return 0;
|
||||
switch (value) {
|
||||
case "none":
|
||||
return 0;
|
||||
case "side":
|
||||
return 1;
|
||||
case "up":
|
||||
return 2;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,82 +11,82 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class TripwireConnectionHandler extends ConnectionHandler {
|
||||
private static Map<Integer, TripwireData> tripwireDataMap = new HashMap<>();
|
||||
private static Map<Byte, Integer> connectedBlocks = new HashMap<>();
|
||||
private static Map<Integer, BlockFace> tripwireHooks = new HashMap<>();
|
||||
private static Map<Integer, TripwireData> tripwireDataMap = new HashMap<>();
|
||||
private static Map<Byte, Integer> connectedBlocks = new HashMap<>();
|
||||
private static Map<Integer, BlockFace> tripwireHooks = new HashMap<>();
|
||||
|
||||
static void init() {
|
||||
TripwireConnectionHandler connectionHandler = new TripwireConnectionHandler();
|
||||
for (Map.Entry<String, Integer> blockState : ConnectionData.keyToId.entrySet()) {
|
||||
String key = blockState.getKey().split("\\[")[0];
|
||||
static void init() {
|
||||
TripwireConnectionHandler connectionHandler = new TripwireConnectionHandler();
|
||||
for (Map.Entry<String, Integer> blockState : ConnectionData.keyToId.entrySet()) {
|
||||
String key = blockState.getKey().split("\\[")[0];
|
||||
|
||||
if (key.equals("minecraft:tripwire_hook")) {
|
||||
WrappedBlockData blockData = WrappedBlockData.fromString(blockState.getKey());
|
||||
tripwireHooks.put(blockState.getValue(), BlockFace.valueOf(blockData.getValue("facing").toUpperCase()));
|
||||
} else if (key.equals("minecraft:tripwire")) {
|
||||
WrappedBlockData blockData = WrappedBlockData.fromString(blockState.getKey());
|
||||
if (key.equals("minecraft:tripwire_hook")) {
|
||||
WrappedBlockData blockData = WrappedBlockData.fromString(blockState.getKey());
|
||||
tripwireHooks.put(blockState.getValue(), BlockFace.valueOf(blockData.getValue("facing").toUpperCase()));
|
||||
} else if (key.equals("minecraft:tripwire")) {
|
||||
WrappedBlockData blockData = WrappedBlockData.fromString(blockState.getKey());
|
||||
|
||||
TripwireData tripwireData = new TripwireData(
|
||||
blockData.getValue("attached").equals("true"),
|
||||
blockData.getValue("disarmed").equals("true"),
|
||||
blockData.getValue("powered").equals("true")
|
||||
);
|
||||
TripwireData tripwireData = new TripwireData(
|
||||
blockData.getValue("attached").equals("true"),
|
||||
blockData.getValue("disarmed").equals("true"),
|
||||
blockData.getValue("powered").equals("true")
|
||||
);
|
||||
|
||||
tripwireDataMap.put(blockState.getValue(), tripwireData);
|
||||
connectedBlocks.put(getStates(blockData), blockState.getValue());
|
||||
tripwireDataMap.put(blockState.getValue(), tripwireData);
|
||||
connectedBlocks.put(getStates(blockData), blockState.getValue());
|
||||
|
||||
ConnectionData.connectionHandlerMap.put(blockState.getValue(), connectionHandler);
|
||||
}
|
||||
}
|
||||
}
|
||||
ConnectionData.connectionHandlerMap.put(blockState.getValue(), connectionHandler);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static byte getStates(WrappedBlockData blockData) {
|
||||
byte b = 0;
|
||||
if (blockData.getValue("attached").equals("true")) b |= 1;
|
||||
if (blockData.getValue("disarmed").equals("true")) b |= 2;
|
||||
if (blockData.getValue("powered").equals("true")) b |= 4;
|
||||
if (blockData.getValue("east").equals("true")) b |= 8;
|
||||
if (blockData.getValue("north").equals("true")) b |= 16;
|
||||
if (blockData.getValue("south").equals("true")) b |= 32;
|
||||
if (blockData.getValue("west").equals("true")) b |= 64;
|
||||
return b;
|
||||
}
|
||||
private static byte getStates(WrappedBlockData blockData) {
|
||||
byte b = 0;
|
||||
if (blockData.getValue("attached").equals("true")) b |= 1;
|
||||
if (blockData.getValue("disarmed").equals("true")) b |= 2;
|
||||
if (blockData.getValue("powered").equals("true")) b |= 4;
|
||||
if (blockData.getValue("east").equals("true")) b |= 8;
|
||||
if (blockData.getValue("north").equals("true")) b |= 16;
|
||||
if (blockData.getValue("south").equals("true")) b |= 32;
|
||||
if (blockData.getValue("west").equals("true")) b |= 64;
|
||||
return b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int connect(UserConnection user, Position position, int blockState) {
|
||||
TripwireData tripwireData = tripwireDataMap.get(blockState);
|
||||
if (tripwireData == null) return blockState;
|
||||
byte b = 0;
|
||||
if (tripwireData.isAttached()) b |= 1;
|
||||
if (tripwireData.isDisarmed()) b |= 2;
|
||||
if (tripwireData.isPowered()) b |= 4;
|
||||
@Override
|
||||
public int connect(UserConnection user, Position position, int blockState) {
|
||||
TripwireData tripwireData = tripwireDataMap.get(blockState);
|
||||
if (tripwireData == null) return blockState;
|
||||
byte b = 0;
|
||||
if (tripwireData.isAttached()) b |= 1;
|
||||
if (tripwireData.isDisarmed()) b |= 2;
|
||||
if (tripwireData.isPowered()) b |= 4;
|
||||
|
||||
int east = getBlockData(user, position.getRelative(BlockFace.EAST));
|
||||
int north = getBlockData(user, position.getRelative(BlockFace.NORTH));
|
||||
int south = getBlockData(user, position.getRelative(BlockFace.SOUTH));
|
||||
int west = getBlockData(user, position.getRelative(BlockFace.WEST));
|
||||
int east = getBlockData(user, position.getRelative(BlockFace.EAST));
|
||||
int north = getBlockData(user, position.getRelative(BlockFace.NORTH));
|
||||
int south = getBlockData(user, position.getRelative(BlockFace.SOUTH));
|
||||
int west = getBlockData(user, position.getRelative(BlockFace.WEST));
|
||||
|
||||
if (tripwireDataMap.containsKey(east) || tripwireHooks.get(east) == BlockFace.WEST) {
|
||||
b |= 8;
|
||||
}
|
||||
if (tripwireDataMap.containsKey(north) || tripwireHooks.get(north) == BlockFace.SOUTH) {
|
||||
b |= 16;
|
||||
}
|
||||
if (tripwireDataMap.containsKey(south) || tripwireHooks.get(south) == BlockFace.NORTH) {
|
||||
b |= 32;
|
||||
}
|
||||
if (tripwireDataMap.containsKey(west) || tripwireHooks.get(west) == BlockFace.EAST) {
|
||||
b |= 64;
|
||||
}
|
||||
if (tripwireDataMap.containsKey(east) || tripwireHooks.get(east) == BlockFace.WEST) {
|
||||
b |= 8;
|
||||
}
|
||||
if (tripwireDataMap.containsKey(north) || tripwireHooks.get(north) == BlockFace.SOUTH) {
|
||||
b |= 16;
|
||||
}
|
||||
if (tripwireDataMap.containsKey(south) || tripwireHooks.get(south) == BlockFace.NORTH) {
|
||||
b |= 32;
|
||||
}
|
||||
if (tripwireDataMap.containsKey(west) || tripwireHooks.get(west) == BlockFace.EAST) {
|
||||
b |= 64;
|
||||
}
|
||||
|
||||
Integer newBlockState = connectedBlocks.get(b);
|
||||
return newBlockState == null ? blockState : newBlockState;
|
||||
}
|
||||
Integer newBlockState = connectedBlocks.get(b);
|
||||
return newBlockState == null ? blockState : newBlockState;
|
||||
}
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
@ToString
|
||||
private static class TripwireData {
|
||||
private final boolean attached, disarmed, powered;
|
||||
}
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
@ToString
|
||||
private static class TripwireData {
|
||||
private final boolean attached, disarmed, powered;
|
||||
}
|
||||
}
|
||||
|
@ -5,8 +5,8 @@ import us.myles.ViaVersion.api.minecraft.BlockFace;
|
||||
import us.myles.ViaVersion.api.minecraft.Position;
|
||||
|
||||
public class WallConnectionHandler extends AbstractFenceConnectionHandler {
|
||||
private static final BlockFace[] BLOCK_FACES = { BlockFace.EAST, BlockFace.NORTH, BlockFace.SOUTH, BlockFace.WEST };
|
||||
private static final int[] OPPOSITES = { 3, 2, 1, 0 };
|
||||
private static final BlockFace[] BLOCK_FACES = {BlockFace.EAST, BlockFace.NORTH, BlockFace.SOUTH, BlockFace.WEST};
|
||||
private static final int[] OPPOSITES = {3, 2, 1, 0};
|
||||
|
||||
static void init() {
|
||||
new WallConnectionHandler("cobbleWallConnections", "minecraft:cobblestone_wall");
|
||||
@ -32,7 +32,8 @@ public class WallConnectionHandler extends AbstractFenceConnectionHandler {
|
||||
}
|
||||
|
||||
public boolean up(UserConnection user, Position position) {
|
||||
if(isWall(getBlockData(user, position.getRelative(BlockFace.BOTTOM))) || isWall(getBlockData(user, position.getRelative(BlockFace.TOP))))return true;
|
||||
if (isWall(getBlockData(user, position.getRelative(BlockFace.BOTTOM))) || isWall(getBlockData(user, position.getRelative(BlockFace.TOP))))
|
||||
return true;
|
||||
int blockFaces = getBlockFaces(user, position);
|
||||
if (blockFaces == 0 || blockFaces == 0xF) return true;
|
||||
for (int i = 0; i < BLOCK_FACES.length; i++) {
|
||||
@ -51,7 +52,7 @@ public class WallConnectionHandler extends AbstractFenceConnectionHandler {
|
||||
return blockFaces;
|
||||
}
|
||||
|
||||
private boolean isWall(int id){
|
||||
private boolean isWall(int id) {
|
||||
return getBlockStates().contains(id);
|
||||
}
|
||||
}
|
||||
|
@ -16,19 +16,27 @@ public class BlockConnectionProvider implements Provider {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void storeBlock(UserConnection connection, Position position, int blockState) {};
|
||||
public void storeBlock(UserConnection connection, Position position, int blockState) {
|
||||
|
||||
public void removeBlock(UserConnection connection, Position position) {};
|
||||
}
|
||||
|
||||
public void removeBlock(UserConnection connection, Position position) {
|
||||
|
||||
}
|
||||
|
||||
public void storeBlock(UserConnection connection, long x, long y, long z, int blockState) {
|
||||
storeBlock(connection, new Position(x, y, z), blockState);
|
||||
}
|
||||
|
||||
public void clearStorage(UserConnection connection) {};
|
||||
public void clearStorage(UserConnection connection) {
|
||||
|
||||
public void unloadChunk(UserConnection connection, int x, int z) {};
|
||||
}
|
||||
|
||||
public boolean storesBlocks(){
|
||||
public void unloadChunk(UserConnection connection, int x, int z) {
|
||||
|
||||
}
|
||||
|
||||
public boolean storesBlocks() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -243,7 +243,7 @@ public class WorldPackets {
|
||||
protocol.registerOutgoing(State.PLAY, 0x1D, 0x1F, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
if(Via.getConfig().isServersideBlockConnections()){
|
||||
if (Via.getConfig().isServersideBlockConnections()) {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
|
@ -34,29 +34,29 @@ public class BlockConnectionStorage extends StoredObject {
|
||||
Pair pair = getPair(position);
|
||||
Map<BlockPositon, Integer> map = getChunkMap(pair);
|
||||
map.remove(new BlockPositon(position));
|
||||
if(map.isEmpty()){
|
||||
if (map.isEmpty()) {
|
||||
blockStorage.remove(pair);
|
||||
}
|
||||
}
|
||||
|
||||
public void clear(){
|
||||
public void clear() {
|
||||
blockStorage.clear();
|
||||
}
|
||||
|
||||
public void unloadChunk(int x, int z){
|
||||
public void unloadChunk(int x, int z) {
|
||||
blockStorage.remove(new Pair<>(x, z));
|
||||
}
|
||||
|
||||
private Map<BlockPositon, Integer> getChunkMap(Pair pair){
|
||||
private Map<BlockPositon, Integer> getChunkMap(Pair pair) {
|
||||
Map<BlockPositon, Integer> map = blockStorage.get(pair);
|
||||
if(map == null){
|
||||
if (map == null) {
|
||||
map = new HashMap<>();
|
||||
blockStorage.put(pair, map);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
private Pair<Integer, Integer> getPair(Position position){
|
||||
private Pair<Integer, Integer> getPair(Position position) {
|
||||
int chunkX = (int) (position.getX() >> 4);
|
||||
int chunkZ = (int) (position.getZ() >> 4);
|
||||
return new Pair<>(chunkX, chunkZ);
|
||||
@ -65,8 +65,9 @@ public class BlockConnectionStorage extends StoredObject {
|
||||
@EqualsAndHashCode
|
||||
@Data
|
||||
private class BlockPositon {
|
||||
int x,y,z;
|
||||
public BlockPositon(Position position){
|
||||
int x, y, z;
|
||||
|
||||
public BlockPositon(Position position) {
|
||||
x = position.getX().intValue();
|
||||
y = position.getY().intValue();
|
||||
z = position.getZ().intValue();
|
||||
|
@ -122,8 +122,8 @@ public class WorldPackets {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
ClientChunks clientChunks = wrapper.user().get(ClientChunks.class);
|
||||
Chunk1_9to1_8Type type = new Chunk1_9to1_8Type(clientChunks);
|
||||
Chunk1_8 chunk = (Chunk1_8) wrapper.read(type);
|
||||
Chunk1_9to1_8Type type = new Chunk1_9to1_8Type(clientChunks);
|
||||
Chunk1_8 chunk = (Chunk1_8) wrapper.read(type);
|
||||
if (chunk.isUnloadPacket()) {
|
||||
wrapper.setId(0x1D);
|
||||
|
||||
@ -313,7 +313,7 @@ public class WorldPackets {
|
||||
if (Via.getConfig().isShieldBlocking()) {
|
||||
EntityTracker tracker = wrapper.user().get(EntityTracker.class);
|
||||
|
||||
if (item != null && Protocol1_9TO1_8.isSword(item.getIdentifier())) {
|
||||
if (item != null && Protocol1_9TO1_8.isSword(item.getId())) {
|
||||
if (hand == 0) {
|
||||
if (!tracker.isBlocking()) {
|
||||
tracker.setBlocking(true);
|
||||
|
@ -113,7 +113,7 @@ public class Chunk1_9to1_8Type extends PartialType<Chunk, ClientChunks> {
|
||||
// Read biome data
|
||||
if (bytesLeft >= BIOME_DATA_LENGTH) {
|
||||
biomeData = new int[BIOME_DATA_LENGTH];
|
||||
for (int i = 0; i < BIOME_DATA_LENGTH; i++){
|
||||
for (int i = 0; i < BIOME_DATA_LENGTH; i++) {
|
||||
biomeData[i] = input.readByte() & 0xFF;
|
||||
}
|
||||
bytesLeft -= BIOME_DATA_LENGTH;
|
||||
|
@ -24,7 +24,7 @@ public class SpongeBlockConnectionProvider extends BlockConnectionProvider {
|
||||
try {
|
||||
block = Class.forName("net.minecraft.block.Block");
|
||||
blockStateIds = ReflectionUtil.get(
|
||||
ReflectionUtil.getStatic(block, "field_176229_d", Object.class),
|
||||
ReflectionUtil.getStatic(block, "field_176229_d", Object.class),
|
||||
"field_148749_a", Map.class);
|
||||
} catch (ClassNotFoundException e) {
|
||||
Via.getPlatform().getLogger().warning("net.minecraft.block.Block not found! Are you using Lantern?");
|
||||
|
@ -53,8 +53,8 @@ public class VelocityServerHandler {
|
||||
// Check if ViaVersion can support that version
|
||||
Object connection = ReflectionUtil.invoke(e.getPlayer(), "getConnection");
|
||||
setNextProtocolVersion.invoke(connection, ProtocolVersion.getProtocolVersion(protocols == null
|
||||
? user.get(ProtocolInfo.class).getProtocolVersion()
|
||||
: protocolId));
|
||||
? user.get(ProtocolInfo.class).getProtocolVersion()
|
||||
: protocolId));
|
||||
|
||||
} catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e1) {
|
||||
e1.printStackTrace();
|
||||
@ -133,7 +133,7 @@ public class VelocityServerHandler {
|
||||
}
|
||||
|
||||
Object connection = ReflectionUtil.invoke(e.getPlayer(), "getConnection");
|
||||
ProtocolVersion version = (ProtocolVersion) ReflectionUtil.invoke(connection,"getNextProtocolVersion");
|
||||
ProtocolVersion version = (ProtocolVersion) ReflectionUtil.invoke(connection, "getNextProtocolVersion");
|
||||
setProtocolVersion.invoke(connection, version);
|
||||
}
|
||||
}
|
||||
|
@ -56,21 +56,21 @@ public class ProtocolDetectorService implements Runnable {
|
||||
public static void probeServer(final RegisteredServer serverInfo) {
|
||||
final String key = serverInfo.getServerInfo().getName();
|
||||
serverInfo.ping().thenAccept((serverPing) -> {
|
||||
if (serverPing != null && serverPing.getVersion() != null) {
|
||||
detectedProtocolIds.put(key, serverPing.getVersion().getProtocol());
|
||||
if (((VelocityViaConfig) Via.getConfig()).isVelocityPingSave()) {
|
||||
Map<String, Integer> servers = ((VelocityViaConfig) Via.getConfig()).getVelocityServerProtocols();
|
||||
Integer protocol = servers.get(key);
|
||||
if (protocol != null && protocol == serverPing.getVersion().getProtocol()) {
|
||||
return;
|
||||
}
|
||||
// Ensure we're the only ones writing to the config
|
||||
synchronized (Via.getPlatform().getConfigurationProvider()) {
|
||||
servers.put(key, serverPing.getVersion().getProtocol());
|
||||
}
|
||||
// Save
|
||||
Via.getPlatform().getConfigurationProvider().saveConfig();
|
||||
if (serverPing != null && serverPing.getVersion() != null) {
|
||||
detectedProtocolIds.put(key, serverPing.getVersion().getProtocol());
|
||||
if (((VelocityViaConfig) Via.getConfig()).isVelocityPingSave()) {
|
||||
Map<String, Integer> servers = ((VelocityViaConfig) Via.getConfig()).getVelocityServerProtocols();
|
||||
Integer protocol = servers.get(key);
|
||||
if (protocol != null && protocol == serverPing.getVersion().getProtocol()) {
|
||||
return;
|
||||
}
|
||||
// Ensure we're the only ones writing to the config
|
||||
synchronized (Via.getPlatform().getConfigurationProvider()) {
|
||||
servers.put(key, serverPing.getVersion().getProtocol());
|
||||
}
|
||||
// Save
|
||||
Via.getPlatform().getConfigurationProvider().saveConfig();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren