Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-25 15:50:10 +01:00
Formatting
Dieser Commit ist enthalten in:
Ursprung
fba0a59324
Commit
c1147cb9f7
@ -38,7 +38,7 @@ public class DeathListener extends ViaBukkitListener {
|
||||
@Override
|
||||
public void run() {
|
||||
// If online
|
||||
if(getUserConnection(p) != null) {
|
||||
if (getUserConnection(p) != null) {
|
||||
PacketWrapper wrapper = new PacketWrapper(0x2C, null, getUserConnection(p));
|
||||
try {
|
||||
wrapper.write(Type.VAR_INT, 2); // Event - Entity dead
|
||||
|
@ -248,5 +248,7 @@ public class UserConnection {
|
||||
*
|
||||
* @param packet Raw packet to be sent
|
||||
*/
|
||||
public void sendRawPacketToServer(ByteBuf packet) { sendRawPacketToServer(packet, false); }
|
||||
public void sendRawPacketToServer(ByteBuf packet) {
|
||||
sendRawPacketToServer(packet, false);
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ 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);
|
||||
|
||||
private static Map<BlockFace, BlockFace> opposites = new HashMap<>();
|
||||
|
||||
static {
|
||||
opposites.put(BlockFace.NORTH, BlockFace.SOUTH);
|
||||
opposites.put(BlockFace.SOUTH, BlockFace.NORTH);
|
||||
|
@ -100,7 +100,7 @@ public class MetadataRewriter {
|
||||
public static void handleMetadata(int entityId, EntityType type, List<Metadata> metadatas, UserConnection connection) {
|
||||
for (Metadata metadata : new ArrayList<>(metadatas)) {
|
||||
try {
|
||||
if(metadata.getValue() instanceof Item) {
|
||||
if (metadata.getValue() instanceof Item) {
|
||||
// Apply rewrite
|
||||
EntityIdRewriter.toClientItem((Item) metadata.getValue());
|
||||
}
|
||||
|
@ -8,8 +8,8 @@ public class TranslateRewriter {
|
||||
public static boolean toClient(JsonElement element, UserConnection user) {
|
||||
if (element instanceof JsonObject) {
|
||||
JsonObject obj = (JsonObject) element;
|
||||
if(obj.has("translate")) {
|
||||
if(obj.get("translate").getAsString().equals("chat.type.achievement")) {
|
||||
if (obj.has("translate")) {
|
||||
if (obj.get("translate").getAsString().equals("chat.type.achievement")) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -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()];
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
@ -258,7 +258,7 @@ public class EntityTracker extends StoredObject {
|
||||
} else {
|
||||
wrapper.write(Type.BYTE, (byte) 3);
|
||||
}
|
||||
wrapper.write(Type.STRING_ARRAY, new String[] {getUser().get(ProtocolInfo.class).getUsername()});
|
||||
wrapper.write(Type.STRING_ARRAY, new String[]{getUser().get(ProtocolInfo.class).getUsername()});
|
||||
} else {
|
||||
wrapper.write(Type.BYTE, (byte) 1); // remove team
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren