Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-28 09:00:09 +01:00
Small refactors
Dieser Commit ist enthalten in:
Ursprung
7bea3142bc
Commit
fbcbd33c66
@ -72,7 +72,7 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_12_1, Ser
|
|||||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||||
map(Type.ITEM_ARRAY, Type.FLAT_ITEM_ARRAY); // 1 - Window Values
|
map(Type.ITEM_ARRAY, Type.FLAT_ITEM_ARRAY); // 1 - Window Values
|
||||||
|
|
||||||
handler(itemArrayHandler(Type.FLAT_ITEM_ARRAY));
|
handler(itemArrayToClientHandler(Type.FLAT_ITEM_ARRAY));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
protocol.registerClientbound(ClientboundPackets1_12_1.WINDOW_PROPERTY, new PacketHandlers() {
|
protocol.registerClientbound(ClientboundPackets1_12_1.WINDOW_PROPERTY, new PacketHandlers() {
|
||||||
|
@ -69,7 +69,7 @@ public final class InventoryPackets extends ItemRewriter<ClientboundPackets1_18,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
handler(getSpawnParticleHandler(Type.VAR_INT, Type.FLAT_VAR_INT_ITEM));
|
handler(getSpawnParticleHandler(Type.VAR_INT));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.ClientboundPac
|
|||||||
import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.rewriter.RecipeRewriter1_19_4;
|
import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.rewriter.RecipeRewriter1_19_4;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.Protocol1_20_2To1_20;
|
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.Protocol1_20_2To1_20;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ServerboundPackets1_20_2;
|
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ServerboundPackets1_20_2;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.types.Chunk1_20_2Type;
|
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.type.ChunkType1_20_2;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_20to1_19_4.Protocol1_20To1_19_4;
|
import com.viaversion.viaversion.protocols.protocol1_20to1_19_4.Protocol1_20To1_19_4;
|
||||||
import com.viaversion.viaversion.rewriter.ItemRewriter;
|
import com.viaversion.viaversion.rewriter.ItemRewriter;
|
||||||
import com.viaversion.viaversion.util.MathUtil;
|
import com.viaversion.viaversion.util.MathUtil;
|
||||||
@ -67,7 +67,7 @@ public final class BlockItemPacketRewriter1_20_2 extends ItemRewriter<Clientboun
|
|||||||
MathUtil.ceilLog2(tracker.biomesSent()));
|
MathUtil.ceilLog2(tracker.biomesSent()));
|
||||||
final Chunk chunk = wrapper.read(chunkType);
|
final Chunk chunk = wrapper.read(chunkType);
|
||||||
|
|
||||||
final Type<Chunk> newChunkType = new Chunk1_20_2Type(tracker.currentWorldSectionHeight(),
|
final Type<Chunk> newChunkType = new ChunkType1_20_2(tracker.currentWorldSectionHeight(),
|
||||||
MathUtil.ceilLog2(Protocol1_20To1_19_4.MAPPINGS.getBlockStateMappings().mappedSize()),
|
MathUtil.ceilLog2(Protocol1_20To1_19_4.MAPPINGS.getBlockStateMappings().mappedSize()),
|
||||||
MathUtil.ceilLog2(tracker.biomesSent()));
|
MathUtil.ceilLog2(tracker.biomesSent()));
|
||||||
wrapper.write(newChunkType, chunk);
|
wrapper.write(newChunkType, chunk);
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package com.viaversion.viaversion.protocols.protocol1_20_2to1_20.types;
|
package com.viaversion.viaversion.protocols.protocol1_20_2to1_20.type;
|
||||||
|
|
||||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
@ -31,11 +31,11 @@ import io.netty.buffer.ByteBuf;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public final class Chunk1_20_2Type extends Type<Chunk> {
|
public final class ChunkType1_20_2 extends Type<Chunk> {
|
||||||
private final ChunkSectionType1_18 sectionType;
|
private final ChunkSectionType1_18 sectionType;
|
||||||
private final int ySectionCount;
|
private final int ySectionCount;
|
||||||
|
|
||||||
public Chunk1_20_2Type(final int ySectionCount, final int globalPaletteBlockBits, final int globalPaletteBiomeBits) {
|
public ChunkType1_20_2(final int ySectionCount, final int globalPaletteBlockBits, final int globalPaletteBiomeBits) {
|
||||||
super(Chunk.class);
|
super(Chunk.class);
|
||||||
Preconditions.checkArgument(ySectionCount > 0);
|
Preconditions.checkArgument(ySectionCount > 0);
|
||||||
this.sectionType = new ChunkSectionType1_18(globalPaletteBlockBits, globalPaletteBiomeBits);
|
this.sectionType = new ChunkSectionType1_18(globalPaletteBlockBits, globalPaletteBiomeBits);
|
@ -70,7 +70,7 @@ public abstract class ItemRewriter<C extends ClientboundPacketType, S extends Se
|
|||||||
public void register() {
|
public void register() {
|
||||||
map(Type.UNSIGNED_BYTE); // Window id
|
map(Type.UNSIGNED_BYTE); // Window id
|
||||||
map(type); // Items
|
map(type); // Items
|
||||||
handler(itemArrayHandler(type));
|
handler(itemArrayToClientHandler(type));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -384,7 +384,7 @@ public abstract class ItemRewriter<C extends ClientboundPacketType, S extends Se
|
|||||||
map(Type.FLOAT); // 7 - Offset Z
|
map(Type.FLOAT); // 7 - Offset Z
|
||||||
map(Type.FLOAT); // 8 - Particle Data
|
map(Type.FLOAT); // 8 - Particle Data
|
||||||
map(Type.INT); // 9 - Particle Count
|
map(Type.INT); // 9 - Particle Count
|
||||||
handler(getSpawnParticleHandler(itemType));
|
handler(getSpawnParticleHandler());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -403,16 +403,16 @@ public abstract class ItemRewriter<C extends ClientboundPacketType, S extends Se
|
|||||||
map(Type.FLOAT); // 7 - Offset Z
|
map(Type.FLOAT); // 7 - Offset Z
|
||||||
map(Type.FLOAT); // 8 - Particle Data
|
map(Type.FLOAT); // 8 - Particle Data
|
||||||
map(Type.INT); // 9 - Particle Count
|
map(Type.INT); // 9 - Particle Count
|
||||||
handler(getSpawnParticleHandler(Type.VAR_INT, itemType));
|
handler(getSpawnParticleHandler(Type.VAR_INT));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public PacketHandler getSpawnParticleHandler(Type<Item> itemType) {
|
public PacketHandler getSpawnParticleHandler() {
|
||||||
return getSpawnParticleHandler(Type.INT, itemType);
|
return getSpawnParticleHandler(Type.INT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PacketHandler getSpawnParticleHandler(Type<Integer> idType, Type<Item> itemType) {
|
public PacketHandler getSpawnParticleHandler(Type<Integer> idType) {
|
||||||
return wrapper -> {
|
return wrapper -> {
|
||||||
int id = wrapper.get(idType, 0);
|
int id = wrapper.get(idType, 0);
|
||||||
if (id == -1) {
|
if (id == -1) {
|
||||||
@ -434,8 +434,7 @@ public abstract class ItemRewriter<C extends ClientboundPacketType, S extends Se
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only sent to the client
|
public PacketHandler itemArrayToClientHandler(Type<Item[]> type) {
|
||||||
public PacketHandler itemArrayHandler(Type<Item[]> type) {
|
|
||||||
return wrapper -> {
|
return wrapper -> {
|
||||||
Item[] items = wrapper.get(type, 0);
|
Item[] items = wrapper.get(type, 0);
|
||||||
for (Item item : items) {
|
for (Item item : items) {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren