Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-20 06:50:08 +01:00
Formatting
Dieser Commit ist enthalten in:
Ursprung
fba0a59324
Commit
c1147cb9f7
@ -38,7 +38,7 @@ public class DeathListener extends ViaBukkitListener {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
// If online
|
// If online
|
||||||
if(getUserConnection(p) != null) {
|
if (getUserConnection(p) != null) {
|
||||||
PacketWrapper wrapper = new PacketWrapper(0x2C, null, getUserConnection(p));
|
PacketWrapper wrapper = new PacketWrapper(0x2C, null, getUserConnection(p));
|
||||||
try {
|
try {
|
||||||
wrapper.write(Type.VAR_INT, 2); // Event - Entity dead
|
wrapper.write(Type.VAR_INT, 2); // Event - Entity dead
|
||||||
|
@ -248,5 +248,7 @@ public class UserConnection {
|
|||||||
*
|
*
|
||||||
* @param packet Raw packet to be sent
|
* @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);
|
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<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
opposites.put(BlockFace.NORTH, BlockFace.SOUTH);
|
opposites.put(BlockFace.NORTH, BlockFace.SOUTH);
|
||||||
opposites.put(BlockFace.SOUTH, BlockFace.NORTH);
|
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) {
|
public static void handleMetadata(int entityId, EntityType type, List<Metadata> metadatas, UserConnection connection) {
|
||||||
for (Metadata metadata : new ArrayList<>(metadatas)) {
|
for (Metadata metadata : new ArrayList<>(metadatas)) {
|
||||||
try {
|
try {
|
||||||
if(metadata.getValue() instanceof Item) {
|
if (metadata.getValue() instanceof Item) {
|
||||||
// Apply rewrite
|
// Apply rewrite
|
||||||
EntityIdRewriter.toClientItem((Item) metadata.getValue());
|
EntityIdRewriter.toClientItem((Item) metadata.getValue());
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,8 @@ public class TranslateRewriter {
|
|||||||
public static boolean toClient(JsonElement element, UserConnection user) {
|
public static boolean toClient(JsonElement element, UserConnection user) {
|
||||||
if (element instanceof JsonObject) {
|
if (element instanceof JsonObject) {
|
||||||
JsonObject obj = (JsonObject) element;
|
JsonObject obj = (JsonObject) element;
|
||||||
if(obj.has("translate")) {
|
if (obj.has("translate")) {
|
||||||
if(obj.get("translate").getAsString().equals("chat.type.achievement")) {
|
if (obj.get("translate").getAsString().equals("chat.type.achievement")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ public abstract class AbstractFenceConnectionHandler extends ConnectionHandler {
|
|||||||
private Set<Integer> blockStates = new HashSet<>();
|
private Set<Integer> blockStates = new HashSet<>();
|
||||||
private Map<Byte, Integer> connectedBlockStates = new HashMap<>();
|
private Map<Byte, Integer> connectedBlockStates = new HashMap<>();
|
||||||
|
|
||||||
public AbstractFenceConnectionHandler(String blockConnections, String key){
|
public AbstractFenceConnectionHandler(String blockConnections, String key) {
|
||||||
this.blockConnections = blockConnections;
|
this.blockConnections = blockConnections;
|
||||||
|
|
||||||
for (Map.Entry<String, Integer> blockState : ConnectionData.keyToId.entrySet()) {
|
for (Map.Entry<String, Integer> blockState : ConnectionData.keyToId.entrySet()) {
|
||||||
|
@ -8,11 +8,11 @@ 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) {
|
||||||
final Boolean[] booleans = connectData.get(blockConnection);
|
final Boolean[] booleans = connectData.get(blockConnection);
|
||||||
return booleans != null && booleans[face.ordinal()];
|
return booleans != null && booleans[face.ordinal()];
|
||||||
}
|
}
|
||||||
|
@ -39,11 +39,15 @@ public class RedstoneConnectionHandler extends ConnectionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static int getState(String value) {
|
private static int getState(String value) {
|
||||||
switch (value){
|
switch (value) {
|
||||||
case "none": return 0;
|
case "none":
|
||||||
case "side" : return 1;
|
return 0;
|
||||||
case "up" : return 2;
|
case "side":
|
||||||
default: return 0;
|
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;
|
import us.myles.ViaVersion.api.minecraft.Position;
|
||||||
|
|
||||||
public class WallConnectionHandler extends AbstractFenceConnectionHandler {
|
public class WallConnectionHandler extends AbstractFenceConnectionHandler {
|
||||||
private static final BlockFace[] BLOCK_FACES = { BlockFace.EAST, BlockFace.NORTH, BlockFace.SOUTH, BlockFace.WEST };
|
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 int[] OPPOSITES = {3, 2, 1, 0};
|
||||||
|
|
||||||
static void init() {
|
static void init() {
|
||||||
new WallConnectionHandler("cobbleWallConnections", "minecraft:cobblestone_wall");
|
new WallConnectionHandler("cobbleWallConnections", "minecraft:cobblestone_wall");
|
||||||
@ -32,7 +32,8 @@ public class WallConnectionHandler extends AbstractFenceConnectionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean up(UserConnection user, Position position) {
|
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);
|
int blockFaces = getBlockFaces(user, position);
|
||||||
if (blockFaces == 0 || blockFaces == 0xF) return true;
|
if (blockFaces == 0 || blockFaces == 0xF) return true;
|
||||||
for (int i = 0; i < BLOCK_FACES.length; i++) {
|
for (int i = 0; i < BLOCK_FACES.length; i++) {
|
||||||
@ -51,7 +52,7 @@ public class WallConnectionHandler extends AbstractFenceConnectionHandler {
|
|||||||
return blockFaces;
|
return blockFaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isWall(int id){
|
private boolean isWall(int id) {
|
||||||
return getBlockStates().contains(id);
|
return getBlockStates().contains(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,19 +16,27 @@ public class BlockConnectionProvider implements Provider {
|
|||||||
return -1;
|
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) {
|
public void storeBlock(UserConnection connection, long x, long y, long z, int blockState) {
|
||||||
storeBlock(connection, new Position(x, y, z), 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;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -243,7 +243,7 @@ public class WorldPackets {
|
|||||||
protocol.registerOutgoing(State.PLAY, 0x1D, 0x1F, new PacketRemapper() {
|
protocol.registerOutgoing(State.PLAY, 0x1D, 0x1F, new PacketRemapper() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void registerMap() {
|
||||||
if(Via.getConfig().isServersideBlockConnections()){
|
if (Via.getConfig().isServersideBlockConnections()) {
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
@ -34,29 +34,29 @@ public class BlockConnectionStorage extends StoredObject {
|
|||||||
Pair pair = getPair(position);
|
Pair pair = getPair(position);
|
||||||
Map<BlockPositon, Integer> map = getChunkMap(pair);
|
Map<BlockPositon, Integer> map = getChunkMap(pair);
|
||||||
map.remove(new BlockPositon(position));
|
map.remove(new BlockPositon(position));
|
||||||
if(map.isEmpty()){
|
if (map.isEmpty()) {
|
||||||
blockStorage.remove(pair);
|
blockStorage.remove(pair);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clear(){
|
public void clear() {
|
||||||
blockStorage.clear();
|
blockStorage.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unloadChunk(int x, int z){
|
public void unloadChunk(int x, int z) {
|
||||||
blockStorage.remove(new Pair<>(x, 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);
|
Map<BlockPositon, Integer> map = blockStorage.get(pair);
|
||||||
if(map == null){
|
if (map == null) {
|
||||||
map = new HashMap<>();
|
map = new HashMap<>();
|
||||||
blockStorage.put(pair, map);
|
blockStorage.put(pair, map);
|
||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Pair<Integer, Integer> getPair(Position position){
|
private Pair<Integer, Integer> getPair(Position position) {
|
||||||
int chunkX = (int) (position.getX() >> 4);
|
int chunkX = (int) (position.getX() >> 4);
|
||||||
int chunkZ = (int) (position.getZ() >> 4);
|
int chunkZ = (int) (position.getZ() >> 4);
|
||||||
return new Pair<>(chunkX, chunkZ);
|
return new Pair<>(chunkX, chunkZ);
|
||||||
@ -65,8 +65,9 @@ public class BlockConnectionStorage extends StoredObject {
|
|||||||
@EqualsAndHashCode
|
@EqualsAndHashCode
|
||||||
@Data
|
@Data
|
||||||
private class BlockPositon {
|
private class BlockPositon {
|
||||||
int x,y,z;
|
int x, y, z;
|
||||||
public BlockPositon(Position position){
|
|
||||||
|
public BlockPositon(Position position) {
|
||||||
x = position.getX().intValue();
|
x = position.getX().intValue();
|
||||||
y = position.getY().intValue();
|
y = position.getY().intValue();
|
||||||
z = position.getZ().intValue();
|
z = position.getZ().intValue();
|
||||||
|
@ -258,7 +258,7 @@ public class EntityTracker extends StoredObject {
|
|||||||
} else {
|
} else {
|
||||||
wrapper.write(Type.BYTE, (byte) 3);
|
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 {
|
} else {
|
||||||
wrapper.write(Type.BYTE, (byte) 1); // remove team
|
wrapper.write(Type.BYTE, (byte) 1); // remove team
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ public class Chunk1_9to1_8Type extends PartialType<Chunk, ClientChunks> {
|
|||||||
// Read biome data
|
// Read biome data
|
||||||
if (bytesLeft >= BIOME_DATA_LENGTH) {
|
if (bytesLeft >= BIOME_DATA_LENGTH) {
|
||||||
biomeData = new int[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;
|
biomeData[i] = input.readByte() & 0xFF;
|
||||||
}
|
}
|
||||||
bytesLeft -= BIOME_DATA_LENGTH;
|
bytesLeft -= BIOME_DATA_LENGTH;
|
||||||
|
@ -133,7 +133,7 @@ public class VelocityServerHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Object connection = ReflectionUtil.invoke(e.getPlayer(), "getConnection");
|
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);
|
setProtocolVersion.invoke(connection, version);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren