Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-26 00:00:28 +01:00
18w07c - Handlers
Dieser Commit ist enthalten in:
Ursprung
700f0c293e
Commit
d7caf2ae3c
@ -10,6 +10,7 @@ import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.ProtocolSnapshotTo
|
||||
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.providers.blockentities.BannerHandler;
|
||||
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.providers.blockentities.BedHandler;
|
||||
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.providers.blockentities.FlowerPotHandler;
|
||||
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.providers.blockentities.SkullHandler;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@ -21,6 +22,7 @@ public class BlockEntityProvider implements Provider {
|
||||
handlers.put("minecraft:flower_pot", new FlowerPotHandler());
|
||||
handlers.put("minecraft:bed", new BedHandler());
|
||||
handlers.put("minecraft:banner", new BannerHandler());
|
||||
handlers.put("minecraft:skull", new SkullHandler());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -8,11 +8,11 @@ import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.providers.BlockEnt
|
||||
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.storage.BlockStorage;
|
||||
|
||||
public class BannerHandler implements BlockEntityProvider.BlockEntityHandler {
|
||||
private final int WALL_BANNER_START = 5633; // 4 each
|
||||
private final int WALL_BANNER_STOP = 5696;
|
||||
private final int WALL_BANNER_START = 5783; // 4 each
|
||||
private final int WALL_BANNER_STOP = 5846;
|
||||
|
||||
private final int BANNER_START = 5377; // 16 each
|
||||
private final int BANNER_STOP = 5632;
|
||||
private final int BANNER_START = 5527; // 16 each
|
||||
private final int BANNER_STOP = 5782;
|
||||
|
||||
@Override
|
||||
public int transform(UserConnection user, CompoundTag tag) {
|
||||
|
@ -20,7 +20,7 @@ public class BedHandler implements BlockEntityProvider.BlockEntityHandler {
|
||||
}
|
||||
|
||||
// RED_BED + FIRST_BED
|
||||
int blockId = storage.get(position).getOriginal() - 896 + 672;
|
||||
int blockId = storage.get(position).getOriginal() - 914 + 690;
|
||||
|
||||
int color = (int) tag.get("color").getValue();
|
||||
blockId += (color * 16);
|
||||
|
@ -12,28 +12,28 @@ public class FlowerPotHandler implements BlockEntityProvider.BlockEntityHandler
|
||||
private static final Map<Pair<String, Integer>, Integer> flowers = new ConcurrentHashMap<>();
|
||||
|
||||
static {
|
||||
register("minecraft:air", 0, 4466);
|
||||
register("minecraft:sapling", 0, 4467);
|
||||
register("minecraft:sapling", 1, 4468);
|
||||
register("minecraft:sapling", 2, 4469);
|
||||
register("minecraft:sapling", 3, 4470);
|
||||
register("minecraft:sapling", 4, 4471);
|
||||
register("minecraft:sapling", 5, 4472);
|
||||
register("minecraft:tallgrass", 2, 4473);
|
||||
register("minecraft:yellow_flower", 0, 4474);
|
||||
register("minecraft:red_flower", 0, 4475);
|
||||
register("minecraft:red_flower", 1, 4476);
|
||||
register("minecraft:red_flower", 2, 4477);
|
||||
register("minecraft:red_flower", 3, 4478);
|
||||
register("minecraft:red_flower", 4, 4479);
|
||||
register("minecraft:red_flower", 5, 4480);
|
||||
register("minecraft:red_flower", 6, 4481);
|
||||
register("minecraft:red_flower", 7, 4482);
|
||||
register("minecraft:red_flower", 8, 4483);
|
||||
register("minecraft:red_mushroom", 0, 4484);
|
||||
register("minecraft:brown_mushroom", 0, 4485);
|
||||
register("minecraft:deadbush", 0, 4486);
|
||||
register("minecraft:cactus", 0, 4487);
|
||||
register("minecraft:air", 0, 4487);
|
||||
register("minecraft:sapling", 0, 4488);
|
||||
register("minecraft:sapling", 1, 4489);
|
||||
register("minecraft:sapling", 2, 4490);
|
||||
register("minecraft:sapling", 3, 4491);
|
||||
register("minecraft:sapling", 4, 4492);
|
||||
register("minecraft:sapling", 5, 4493);
|
||||
register("minecraft:tallgrass", 2, 4494);
|
||||
register("minecraft:yellow_flower", 0, 4495);
|
||||
register("minecraft:red_flower", 0, 4496);
|
||||
register("minecraft:red_flower", 1, 4497);
|
||||
register("minecraft:red_flower", 2, 4498);
|
||||
register("minecraft:red_flower", 3, 4499);
|
||||
register("minecraft:red_flower", 4, 4500);
|
||||
register("minecraft:red_flower", 5, 4501);
|
||||
register("minecraft:red_flower", 6, 4502);
|
||||
register("minecraft:red_flower", 7, 4503);
|
||||
register("minecraft:red_flower", 8, 4504);
|
||||
register("minecraft:red_mushroom", 0, 4505);
|
||||
register("minecraft:brown_mushroom", 0, 4506);
|
||||
register("minecraft:deadbush", 0, 4507);
|
||||
register("minecraft:cactus", 0, 4508);
|
||||
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,55 @@
|
||||
package us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.providers.blockentities;
|
||||
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.minecraft.Position;
|
||||
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.providers.BlockEntityProvider;
|
||||
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.storage.BlockStorage;
|
||||
|
||||
public class SkullHandler implements BlockEntityProvider.BlockEntityHandler {
|
||||
@Override
|
||||
public int transform(UserConnection user, CompoundTag tag) {
|
||||
BlockStorage storage = user.get(BlockStorage.class);
|
||||
Position position = new Position(getLong(tag.get("x")), getLong(tag.get("y")), getLong(tag.get("z")));
|
||||
|
||||
if (!storage.contains(position)) {
|
||||
System.out.println("Received an head update packet, but there is no head! O_o " + tag);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int data = storage.get(position).getOriginal() & 0xF;
|
||||
|
||||
byte type = (Byte) tag.get("SkullType").getValue();
|
||||
|
||||
int add = 0;
|
||||
|
||||
// wall head start
|
||||
int blockId = 4669;
|
||||
|
||||
switch (data % 6) {
|
||||
case 1:
|
||||
add = (Byte) tag.get("Rot").getValue() + 4;
|
||||
break;
|
||||
case 2:
|
||||
add = 0;
|
||||
break;
|
||||
case 3:
|
||||
add = 2;
|
||||
break;
|
||||
case 4:
|
||||
add = 3;
|
||||
break;
|
||||
case 5:
|
||||
add = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
blockId += add + type * 20;
|
||||
|
||||
return blockId;
|
||||
}
|
||||
private long getLong(Tag tag) {
|
||||
return ((Integer) tag.getValue()).longValue();
|
||||
}
|
||||
}
|
@ -17,20 +17,24 @@ public class BlockStorage extends StoredObject {
|
||||
|
||||
static {
|
||||
// Flower pots
|
||||
whitelist.add(4466);
|
||||
whitelist.add(4487);
|
||||
|
||||
// Add those red beds
|
||||
for (int i = 0; i < 16; i++)
|
||||
whitelist.add(896 + i);
|
||||
whitelist.add(914 + i);
|
||||
|
||||
// Add the white banners
|
||||
for (int i = 0; i < 20; i++)
|
||||
whitelist.add(5377 + i);
|
||||
whitelist.add(5527 + i);
|
||||
|
||||
// Add the whhite wall banners
|
||||
// Add the white wall banners
|
||||
for (int i = 0; i < 4; i++) {
|
||||
whitelist.add(5633 + i);
|
||||
whitelist.add(5783 + i);
|
||||
}
|
||||
|
||||
// Skulls
|
||||
for (int i = 0; i < 5; i++)
|
||||
whitelist.add(4669 + i);
|
||||
}
|
||||
|
||||
private Map<Position, ReplacementData> blocks = new ConcurrentHashMap<>();
|
||||
|
@ -3,13 +3,22 @@ package us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.type;
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.minecraft.Environment;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
||||
import us.myles.ViaVersion.api.type.PartialType;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.api.type.types.minecraft.BaseChunkType;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.chunks.Chunk1_9_3_4;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.chunks.ChunkSection1_9_3_4;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.BitSet;
|
||||
import java.util.List;
|
||||
|
||||
public class Chunk1_13Type extends PartialType<Chunk, ClientWorld> {
|
||||
public Chunk1_13Type(ClientWorld param) {
|
||||
super(param, Chunk.class);
|
||||
@ -17,7 +26,51 @@ public class Chunk1_13Type extends PartialType<Chunk, ClientWorld> {
|
||||
|
||||
@Override
|
||||
public Chunk read(ByteBuf input, ClientWorld world) throws Exception {
|
||||
throw new UnsupportedOperationException(); // TODO
|
||||
int chunkX = input.readInt();
|
||||
int chunkZ = input.readInt();
|
||||
|
||||
boolean groundUp = input.readBoolean();
|
||||
int primaryBitmask = Type.VAR_INT.read(input);
|
||||
Type.VAR_INT.read(input);
|
||||
|
||||
BitSet usedSections = new BitSet(16);
|
||||
ChunkSection1_9_3_4[] sections = new ChunkSection1_9_3_4[16];
|
||||
// Calculate section count from bitmask
|
||||
for (int i = 0; i < 16; i++) {
|
||||
if ((primaryBitmask & (1 << i)) != 0) {
|
||||
usedSections.set(i);
|
||||
}
|
||||
}
|
||||
|
||||
// Read sections
|
||||
for (int i = 0; i < 16; i++) {
|
||||
if (!usedSections.get(i)) continue; // Section not set
|
||||
ChunkSection1_9_3_4 section = new ChunkSection1_9_3_4();
|
||||
sections[i] = section;
|
||||
section.readBlocks(input);
|
||||
section.readBlockLight(input);
|
||||
if (world.getEnvironment() == Environment.NORMAL) {
|
||||
section.readSkyLight(input);
|
||||
}
|
||||
}
|
||||
|
||||
byte[] biomeData = groundUp ? new byte[256] : null;
|
||||
if (groundUp) {
|
||||
for (int i = 0; i < 256; i++){
|
||||
biomeData[i] = (byte) input.readInt();
|
||||
}
|
||||
}
|
||||
|
||||
List<CompoundTag> nbtData = new ArrayList<>(Arrays.asList(Type.NBT_ARRAY.read(input)));
|
||||
|
||||
// Read all the remaining bytes (workaround for #681)
|
||||
if (input.readableBytes() > 0) {
|
||||
byte[] array = Type.REMAINING_BYTES.read(input);
|
||||
if (Via.getManager().isDebug())
|
||||
System.out.println("Found " + array.length + " more bytes than expected while reading the chunk: " + chunkX + "/" + chunkZ);
|
||||
}
|
||||
|
||||
return new Chunk1_9_3_4(chunkX, chunkZ, groundUp, primaryBitmask, sections, biomeData, nbtData);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -939,11 +939,11 @@
|
||||
"2300": "minecraft:oak_button[face=wall,facing=north,powered=true]",
|
||||
"2301": "minecraft:oak_button[face=floor,facing=north,powered=true]",
|
||||
"2304": "%%FILTER_ME%%[facing=down,nodrop=false]",
|
||||
"2305": "%%FILTER_ME%%[facing=up,nodrop=false]",
|
||||
"2306": "%%FILTER_ME%%[facing=north,nodrop=false]",
|
||||
"2307": "%%FILTER_ME%%[facing=south,nodrop=false]",
|
||||
"2308": "%%FILTER_ME%%[facing=west,nodrop=false]",
|
||||
"2309": "%%FILTER_ME%%[facing=east,nodrop=false]",
|
||||
"2305": "minecraft:skeleton_skull[rotation=0]",
|
||||
"2306": "minecraft:skeleton_wall_skull[facing=north]",
|
||||
"2307": "minecraft:skeleton_wall_skull[facing=south]",
|
||||
"2308": "minecraft:skeleton_wall_skull[facing=west]",
|
||||
"2309": "minecraft:skeleton_wall_skull[facing=east]",
|
||||
"2312": "%%FILTER_ME%%[facing=down,nodrop=true]",
|
||||
"2313": "%%FILTER_ME%%[facing=up,nodrop=true]",
|
||||
"2314": "%%FILTER_ME%%[facing=north,nodrop=true]",
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren