mirror of
https://github.com/ViaVersion/ViaAprilFools.git
synced 2025-01-22 21:21:26 +01:00
Merge pull request #10 from FlorianMichael/via-update-2
Updated Via* and API usage
This commit is contained in:
commit
77726fda96
@ -20,8 +20,8 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly "com.viaversion:viaversion:4.7.0-23w17a-SNAPSHOT"
|
compileOnly "com.viaversion:viaversion:4.7.0-23w18a-SNAPSHOT"
|
||||||
compileOnly("com.viaversion:viabackwards-common:4.7.0-23w17a-SNAPSHOT") {
|
compileOnly("com.viaversion:viabackwards-common:4.7.0-23w18a-SNAPSHOT") {
|
||||||
exclude group: "com.viaversion", module: "viaversion"
|
exclude group: "com.viaversion", module: "viaversion"
|
||||||
}
|
}
|
||||||
compileOnly "org.yaml:snakeyaml:2.0"
|
compileOnly "org.yaml:snakeyaml:2.0"
|
||||||
|
@ -57,34 +57,25 @@ public class Protocol1_14to3D_Shareware extends BackwardsProtocol<ClientboundPac
|
|||||||
soundRewriter.registerNamedSound(ClientboundPackets3D_Shareware.NAMED_SOUND);
|
soundRewriter.registerNamedSound(ClientboundPackets3D_Shareware.NAMED_SOUND);
|
||||||
soundRewriter.registerStopSound(ClientboundPackets3D_Shareware.STOP_SOUND);
|
soundRewriter.registerStopSound(ClientboundPackets3D_Shareware.STOP_SOUND);
|
||||||
|
|
||||||
this.registerClientbound(ClientboundPackets3D_Shareware.CHUNK_DATA, new PacketHandlers() {
|
this.registerClientbound(ClientboundPackets3D_Shareware.CHUNK_DATA, wrapper -> {
|
||||||
@Override
|
final ChunkCenterTracker3D_Shareware entityTracker = wrapper.user().get(ChunkCenterTracker3D_Shareware.class);
|
||||||
public void register() {
|
|
||||||
handler(wrapper -> {
|
final Chunk chunk = wrapper.passthrough(new Chunk1_14Type());
|
||||||
final Chunk chunk = wrapper.passthrough(new Chunk1_14Type());
|
final int diffX = Math.abs(entityTracker.getChunkCenterX() - chunk.getX());
|
||||||
ChunkCenterTracker3D_Shareware entityTracker = wrapper.user().get(ChunkCenterTracker3D_Shareware.class);
|
final int diffZ = Math.abs(entityTracker.getChunkCenterZ() - chunk.getZ());
|
||||||
final int diffX = Math.abs(entityTracker.getChunkCenterX() - chunk.getX());
|
|
||||||
final int diffZ = Math.abs(entityTracker.getChunkCenterZ() - chunk.getZ());
|
if (entityTracker.isForceSendCenterChunk() || diffX >= SERVERSIDE_VIEW_DISTANCE || diffZ >= SERVERSIDE_VIEW_DISTANCE) {
|
||||||
if (entityTracker.isForceSendCenterChunk() || diffX >= SERVERSIDE_VIEW_DISTANCE || diffZ >= SERVERSIDE_VIEW_DISTANCE) {
|
final PacketWrapper fakePosLook = wrapper.create(ClientboundPackets1_14.UPDATE_VIEW_POSITION); // Set center chunk
|
||||||
final PacketWrapper fakePosLook = wrapper.create(ClientboundPackets1_14.UPDATE_VIEW_POSITION); // Set center chunk
|
fakePosLook.write(Type.VAR_INT, chunk.getX());
|
||||||
fakePosLook.write(Type.VAR_INT, chunk.getX());
|
fakePosLook.write(Type.VAR_INT, chunk.getZ());
|
||||||
fakePosLook.write(Type.VAR_INT, chunk.getZ());
|
fakePosLook.send(Protocol1_14to3D_Shareware.class);
|
||||||
fakePosLook.send(Protocol1_14to3D_Shareware.class);
|
entityTracker.setChunkCenterX(chunk.getX());
|
||||||
entityTracker.setChunkCenterX(chunk.getX());
|
entityTracker.setChunkCenterZ(chunk.getZ());
|
||||||
entityTracker.setChunkCenterZ(chunk.getZ());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.registerClientbound(ClientboundPackets3D_Shareware.RESPAWN, new PacketHandlers() {
|
this.registerClientbound(ClientboundPackets3D_Shareware.RESPAWN, wrapper -> {
|
||||||
@Override
|
// The client may reset the center chunk if dimension is changed
|
||||||
public void register() {
|
wrapper.user().get(ChunkCenterTracker3D_Shareware.class).setForceSendCenterChunk(true);
|
||||||
handler(wrapper -> {
|
|
||||||
ChunkCenterTracker3D_Shareware entityTracker = wrapper.user().get(ChunkCenterTracker3D_Shareware.class);
|
|
||||||
// The client may reset the center chunk if dimension is changed
|
|
||||||
entityTracker.setForceSendCenterChunk(true);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,9 +40,7 @@ public class Protocol1_16_2toCombatTest8c extends AbstractProtocol<ClientboundPa
|
|||||||
map(Type.BOOLEAN); //chatColors
|
map(Type.BOOLEAN); //chatColors
|
||||||
map(Type.UNSIGNED_BYTE); //playerModelBitMask
|
map(Type.UNSIGNED_BYTE); //playerModelBitMask
|
||||||
map(Type.VAR_INT); //mainArm
|
map(Type.VAR_INT); //mainArm
|
||||||
handler(wrapper -> {
|
handler(wrapper -> wrapper.write(Type.BOOLEAN, false)); //useShieldOnCrouch
|
||||||
wrapper.write(Type.BOOLEAN, false); //useShieldOnCrouch
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -116,8 +116,8 @@ public class Protocol1_16to20w14infinite extends BackwardsProtocol<ClientboundPa
|
|||||||
map(Type.BYTE); // Flags
|
map(Type.BYTE); // Flags
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
final PlayerAbilitiesProvider playerAbilities = Via.getManager().getProviders().get(PlayerAbilitiesProvider.class);
|
final PlayerAbilitiesProvider playerAbilities = Via.getManager().getProviders().get(PlayerAbilitiesProvider.class);
|
||||||
wrapper.write(Type.FLOAT, playerAbilities.getFlyingSpeed());
|
wrapper.write(Type.FLOAT, playerAbilities.getFlyingSpeed(wrapper.user()));
|
||||||
wrapper.write(Type.FLOAT, playerAbilities.getWalkingSpeed());
|
wrapper.write(Type.FLOAT, playerAbilities.getWalkingSpeed(wrapper.user()));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -69,32 +69,24 @@ public class EntityPackets20w14infinite {
|
|||||||
metadataRewriter.registerRemoveEntities(ClientboundPackets20w14infinite.DESTROY_ENTITIES);
|
metadataRewriter.registerRemoveEntities(ClientboundPackets20w14infinite.DESTROY_ENTITIES);
|
||||||
|
|
||||||
// Spawn lightning -> Spawn entity
|
// Spawn lightning -> Spawn entity
|
||||||
protocol.registerClientbound(ClientboundPackets20w14infinite.SPAWN_GLOBAL_ENTITY, ClientboundPackets1_16.SPAWN_ENTITY, new PacketHandlers() {
|
protocol.registerClientbound(ClientboundPackets20w14infinite.SPAWN_GLOBAL_ENTITY, ClientboundPackets1_16.SPAWN_ENTITY, wrapper -> {
|
||||||
@Override
|
final int entityId = wrapper.passthrough(Type.VAR_INT); // entity id
|
||||||
public void register() {
|
wrapper.user().getEntityTracker(Protocol1_16to20w14infinite.class).addEntity(entityId, Entity1_16Types.LIGHTNING_BOLT);
|
||||||
handler(new PacketHandler() {
|
|
||||||
@Override
|
|
||||||
public void handle(PacketWrapper packetWrapper) throws Exception {
|
|
||||||
int entityId = packetWrapper.passthrough(Type.VAR_INT); // entity id
|
|
||||||
packetWrapper.user().getEntityTracker(Protocol1_16to20w14infinite.class).addEntity(entityId, Entity1_16Types.LIGHTNING_BOLT);
|
|
||||||
|
|
||||||
packetWrapper.write(Type.UUID, UUID.randomUUID()); // uuid
|
wrapper.write(Type.UUID, UUID.randomUUID()); // uuid
|
||||||
packetWrapper.write(Type.VAR_INT, Entity1_16Types.LIGHTNING_BOLT.getId()); // entity type
|
wrapper.write(Type.VAR_INT, Entity1_16Types.LIGHTNING_BOLT.getId()); // entity type
|
||||||
|
|
||||||
packetWrapper.read(Type.BYTE); // remove type
|
wrapper.read(Type.BYTE); // remove type
|
||||||
|
|
||||||
packetWrapper.passthrough(Type.DOUBLE); // x
|
wrapper.passthrough(Type.DOUBLE); // x
|
||||||
packetWrapper.passthrough(Type.DOUBLE); // y
|
wrapper.passthrough(Type.DOUBLE); // y
|
||||||
packetWrapper.passthrough(Type.DOUBLE); // z
|
wrapper.passthrough(Type.DOUBLE); // z
|
||||||
packetWrapper.write(Type.BYTE, (byte) 0); // yaw
|
wrapper.write(Type.BYTE, (byte) 0); // yaw
|
||||||
packetWrapper.write(Type.BYTE, (byte) 0); // pitch
|
wrapper.write(Type.BYTE, (byte) 0); // pitch
|
||||||
packetWrapper.write(Type.INT, 0); // data
|
wrapper.write(Type.INT, 0); // data
|
||||||
packetWrapper.write(Type.SHORT, (short) 0); // velocity
|
wrapper.write(Type.SHORT, (short) 0); // velocity
|
||||||
packetWrapper.write(Type.SHORT, (short) 0); // velocity
|
wrapper.write(Type.SHORT, (short) 0); // velocity
|
||||||
packetWrapper.write(Type.SHORT, (short) 0); // velocity
|
wrapper.write(Type.SHORT, (short) 0); // velocity
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
protocol.registerClientbound(ClientboundPackets20w14infinite.RESPAWN, new PacketHandlers() {
|
protocol.registerClientbound(ClientboundPackets20w14infinite.RESPAWN, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
@ -105,7 +97,7 @@ public class EntityPackets20w14infinite {
|
|||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
wrapper.write(Type.BYTE, (byte) -1); // Previous gamemode, set to none
|
wrapper.write(Type.BYTE, (byte) -1); // Previous gamemode, set to none
|
||||||
|
|
||||||
String levelType = wrapper.read(Type.STRING);
|
final String levelType = wrapper.read(Type.STRING);
|
||||||
wrapper.write(Type.BOOLEAN, false); // debug
|
wrapper.write(Type.BOOLEAN, false); // debug
|
||||||
wrapper.write(Type.BOOLEAN, levelType.equals("flat"));
|
wrapper.write(Type.BOOLEAN, levelType.equals("flat"));
|
||||||
wrapper.write(Type.BOOLEAN, true); // keep all playerdata
|
wrapper.write(Type.BOOLEAN, true); // keep all playerdata
|
||||||
@ -138,49 +130,44 @@ public class EntityPackets20w14infinite {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
protocol.registerClientbound(ClientboundPackets20w14infinite.ENTITY_PROPERTIES, new PacketHandlers() {
|
protocol.registerClientbound(ClientboundPackets20w14infinite.ENTITY_PROPERTIES, wrapper -> {
|
||||||
@Override
|
wrapper.passthrough(Type.VAR_INT);
|
||||||
public void register() {
|
int size = wrapper.passthrough(Type.INT);
|
||||||
handler(wrapper -> {
|
int actualSize = size;
|
||||||
wrapper.passthrough(Type.VAR_INT);
|
for (int i = 0; i < size; i++) {
|
||||||
int size = wrapper.passthrough(Type.INT);
|
// Attributes have been renamed and are now namespaced identifiers
|
||||||
int actualSize = size;
|
String key = wrapper.read(Type.STRING);
|
||||||
for (int i = 0; i < size; i++) {
|
String attributeIdentifier = Via.getManager().getProtocolManager().getProtocol(Protocol1_16To1_15_2.class).getMappingData().getAttributeMappings().get(key);
|
||||||
// Attributes have been renamed and are now namespaced identifiers
|
if (attributeIdentifier == null) {
|
||||||
String key = wrapper.read(Type.STRING);
|
attributeIdentifier = "minecraft:" + key;
|
||||||
String attributeIdentifier = Via.getManager().getProtocolManager().getProtocol(Protocol1_16To1_15_2.class).getMappingData().getAttributeMappings().get(key);
|
if (!com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.MappingData.isValid1_13Channel(attributeIdentifier)) {
|
||||||
if (attributeIdentifier == null) {
|
if (!Via.getConfig().isSuppressConversionWarnings()) {
|
||||||
attributeIdentifier = "minecraft:" + key;
|
ViaAprilFools.getPlatform().getLogger().warning("Invalid attribute: " + key);
|
||||||
if (!com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.MappingData.isValid1_13Channel(attributeIdentifier)) {
|
|
||||||
if (!Via.getConfig().isSuppressConversionWarnings()) {
|
|
||||||
ViaAprilFools.getPlatform().getLogger().warning("Invalid attribute: " + key);
|
|
||||||
}
|
|
||||||
actualSize--;
|
|
||||||
wrapper.read(Type.DOUBLE);
|
|
||||||
int modifierSize = wrapper.read(Type.VAR_INT);
|
|
||||||
for (int j = 0; j < modifierSize; j++) {
|
|
||||||
wrapper.read(Type.UUID);
|
|
||||||
wrapper.read(Type.DOUBLE);
|
|
||||||
wrapper.read(Type.BYTE);
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
actualSize--;
|
||||||
wrapper.write(Type.STRING, attributeIdentifier);
|
wrapper.read(Type.DOUBLE);
|
||||||
|
int modifierSize = wrapper.read(Type.VAR_INT);
|
||||||
wrapper.passthrough(Type.DOUBLE);
|
|
||||||
int modifierSize = wrapper.passthrough(Type.VAR_INT);
|
|
||||||
for (int j = 0; j < modifierSize; j++) {
|
for (int j = 0; j < modifierSize; j++) {
|
||||||
wrapper.passthrough(Type.UUID);
|
wrapper.read(Type.UUID);
|
||||||
wrapper.passthrough(Type.DOUBLE);
|
wrapper.read(Type.DOUBLE);
|
||||||
wrapper.passthrough(Type.BYTE);
|
wrapper.read(Type.BYTE);
|
||||||
}
|
}
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
if (size != actualSize) {
|
}
|
||||||
wrapper.set(Type.INT, 0, actualSize);
|
|
||||||
}
|
wrapper.write(Type.STRING, attributeIdentifier);
|
||||||
});
|
|
||||||
|
wrapper.passthrough(Type.DOUBLE);
|
||||||
|
int modifierSize = wrapper.passthrough(Type.VAR_INT);
|
||||||
|
for (int j = 0; j < modifierSize; j++) {
|
||||||
|
wrapper.passthrough(Type.UUID);
|
||||||
|
wrapper.passthrough(Type.DOUBLE);
|
||||||
|
wrapper.passthrough(Type.BYTE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (size != actualSize) {
|
||||||
|
wrapper.set(Type.INT, 0, actualSize);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user