Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-12-24 15:20:19 +01:00
Merge branch 'master' into dev
Dieser Commit ist enthalten in:
Commit
bbff706890
@ -26,6 +26,7 @@ import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.packets.EntityP
|
||||
import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.packets.PlayerPackets1_14;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.packets.SoundPackets1_14;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage.ChunkLightStorage;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage.DifficultyStorage;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_14Types;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
@ -195,6 +196,8 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol<ClientboundPackets1_
|
||||
if (!user.has(ChunkLightStorage.class)) {
|
||||
user.put(new ChunkLightStorage(user));
|
||||
}
|
||||
|
||||
user.put(new DifficultyStorage(user));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -23,6 +23,7 @@ import com.viaversion.viabackwards.api.entities.storage.EntityPositionHandler;
|
||||
import com.viaversion.viabackwards.api.rewriters.LegacyEntityRewriter;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.Protocol1_13_2To1_14;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage.ChunkLightStorage;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage.DifficultyStorage;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage.EntityPositionStorage1_14;
|
||||
import com.viaversion.viaversion.api.data.entity.EntityTracker;
|
||||
import com.viaversion.viaversion.api.minecraft.Position;
|
||||
@ -309,10 +310,9 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<Protocol1_13_2To1_14
|
||||
|
||||
handler(getTrackerHandler(Entity1_14Types.PLAYER, Type.INT));
|
||||
handler(getDimensionHandler(1));
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.write(Type.UNSIGNED_BYTE, (short) 0);
|
||||
handler(wrapper -> {
|
||||
short difficulty = wrapper.user().get(DifficultyStorage.class).getDifficulty();
|
||||
wrapper.write(Type.UNSIGNED_BYTE, difficulty);
|
||||
|
||||
wrapper.passthrough(Type.UNSIGNED_BYTE); // Max Players
|
||||
wrapper.passthrough(Type.STRING); // Level Type
|
||||
@ -323,7 +323,6 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<Protocol1_13_2To1_14
|
||||
/*int entitiyId = wrapper.get(Type.INT, 0);
|
||||
StoredEntityData storedEntity = protocol.getEntityRewriter().tracker(wrapper.user()).entityData(entitiyId);
|
||||
storedEntity.put(new EntityPositionStorage1_14());*/
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -333,16 +332,15 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<Protocol1_13_2To1_14
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Dimension ID
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
int dimensionId = wrapper.get(Type.INT, 0);
|
||||
clientWorld.setEnvironment(dimensionId);
|
||||
|
||||
wrapper.write(Type.UNSIGNED_BYTE, (short) 0); // Difficulty
|
||||
short difficulty = wrapper.user().get(DifficultyStorage.class).getDifficulty();
|
||||
wrapper.write(Type.UNSIGNED_BYTE, difficulty);
|
||||
|
||||
wrapper.user().get(ChunkLightStorage.class).clear();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -18,6 +18,7 @@
|
||||
package com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.packets;
|
||||
|
||||
import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.Protocol1_13_2To1_14;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage.DifficultyStorage;
|
||||
import com.viaversion.viaversion.api.minecraft.Position;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
@ -40,6 +41,10 @@ public class PlayerPackets1_14 extends RewriterBase<Protocol1_13_2To1_14> {
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE);
|
||||
map(Type.BOOLEAN, Type.NOTHING); // Locked
|
||||
handler(wrapper -> {
|
||||
byte difficulty = wrapper.get(Type.UNSIGNED_BYTE, 0).byteValue();
|
||||
wrapper.user().get(DifficultyStorage.class).setDifficulty(difficulty);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.StoredObject;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
|
||||
public class DifficultyStorage extends StoredObject {
|
||||
private byte difficulty;
|
||||
|
||||
public DifficultyStorage(UserConnection user) {
|
||||
super(user);
|
||||
}
|
||||
|
||||
public byte getDifficulty() {
|
||||
return difficulty;
|
||||
}
|
||||
|
||||
public void setDifficulty(byte difficulty) {
|
||||
this.difficulty = difficulty;
|
||||
}
|
||||
}
|
@ -30,6 +30,9 @@ import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.LongArrayTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2;
|
||||
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ServerboundPackets1_16_2;
|
||||
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.types.Chunk1_16_2Type;
|
||||
@ -38,6 +41,8 @@ import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ClientboundPacke
|
||||
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ServerboundPackets1_17;
|
||||
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.types.Chunk1_17Type;
|
||||
import com.viaversion.viaversion.rewriter.BlockRewriter;
|
||||
import com.viaversion.viaversion.util.CompactArrayUtil;
|
||||
import com.viaversion.viaversion.util.MathUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@ -282,6 +287,16 @@ public final class BlockItemPackets1_17 extends ItemRewriter<Protocol1_16_4To1_1
|
||||
ChunkSection[] sections = Arrays.copyOfRange(chunk.getSections(), startFromSection, startFromSection + 16);
|
||||
chunk.setSections(sections);
|
||||
|
||||
CompoundTag heightMaps = chunk.getHeightMap();
|
||||
for (Tag heightMapTag : heightMaps.values()) {
|
||||
LongArrayTag heightMap = (LongArrayTag) heightMapTag;
|
||||
int[] heightMapData = new int[256];
|
||||
int bitsPerEntry = MathUtil.ceilLog2((currentWorldSectionHeight << 4) + 1);
|
||||
// Shift back to 0 based and clamp to normal height with 9 bits
|
||||
CompactArrayUtil.iterateCompactArrayWithPadding(bitsPerEntry, heightMapData.length, heightMap.getValue(), (i, v) -> heightMapData[i] = MathUtil.clamp(v + tracker.currentMinY(), 0, 255));
|
||||
heightMap.setValue(CompactArrayUtil.createCompactArrayWithPadding(9, heightMapData.length, i -> heightMapData[i]));
|
||||
}
|
||||
|
||||
for (int i = 0; i < 16; i++) {
|
||||
ChunkSection section = sections[i];
|
||||
if (section == null) continue;
|
||||
|
@ -218,8 +218,8 @@ public final class EntityPackets1_17 extends EntityRewriter<Protocol1_16_4To1_17
|
||||
IntTag logicalHeight = tag.get("logical_height");
|
||||
if (minY.asInt() != 0 || height.asInt() > 256 || logicalHeight.asInt() > 256) {
|
||||
if (warn && !warned) {
|
||||
ViaBackwards.getPlatform().getLogger().severe("Custom worlds heights are NOT SUPPORTED for 1.16 players and older and may lead to errors!");
|
||||
ViaBackwards.getPlatform().getLogger().severe("You have min/max set to " + minY.asInt() + "/" + height.asInt());
|
||||
ViaBackwards.getPlatform().getLogger().warning("Custom worlds heights are NOT SUPPORTED for 1.16 players and older and may lead to errors!");
|
||||
ViaBackwards.getPlatform().getLogger().warning("You have min/max set to " + minY.asInt() + "/" + height.asInt());
|
||||
warned = true;
|
||||
}
|
||||
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren