Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-11-20 06:50:10 +01:00
Move methods in LegacyBlockItemRewriter and expose handleChunk method (#707)
Dieser Commit ist enthalten in:
Ursprung
b438484dc7
Commit
4547d5c702
@ -66,10 +66,6 @@ public abstract class LegacyBlockItemRewriter<C extends ClientboundPacketType, S
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected JsonObject readMappingsFile(final String name) {
|
|
||||||
return BackwardsMappingDataLoader.INSTANCE.loadFromDataDir(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addMapping(String key, JsonObject object, Int2ObjectMap<MappedLegacyBlockItem> mappings) {
|
private void addMapping(String key, JsonObject object, Int2ObjectMap<MappedLegacyBlockItem> mappings) {
|
||||||
int id = object.getAsJsonPrimitive("id").getAsInt();
|
int id = object.getAsJsonPrimitive("id").getAsInt();
|
||||||
JsonPrimitive jsonData = object.getAsJsonPrimitive("data");
|
JsonPrimitive jsonData = object.getAsJsonPrimitive("data");
|
||||||
@ -206,16 +202,6 @@ public abstract class LegacyBlockItemRewriter<C extends ClientboundPacketType, S
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int handleBlockId(final int rawId) {
|
|
||||||
final int id = Block.getId(rawId);
|
|
||||||
final int data = Block.getData(rawId);
|
|
||||||
|
|
||||||
final Block mappedBlock = handleBlock(id, data);
|
|
||||||
if (mappedBlock == null) return rawId;
|
|
||||||
|
|
||||||
return Block.toRawId(mappedBlock.getId(), mappedBlock.getData());
|
|
||||||
}
|
|
||||||
|
|
||||||
public PacketHandler getFallingBlockHandler() {
|
public PacketHandler getFallingBlockHandler() {
|
||||||
return wrapper -> {
|
return wrapper -> {
|
||||||
final Optional<EntityTypes1_12.ObjectType> type = EntityTypes1_12.ObjectType.findById(wrapper.get(Type.BYTE, 0));
|
final Optional<EntityTypes1_12.ObjectType> type = EntityTypes1_12.ObjectType.findById(wrapper.get(Type.BYTE, 0));
|
||||||
@ -242,17 +228,17 @@ public abstract class LegacyBlockItemRewriter<C extends ClientboundPacketType, S
|
|||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
|
|
||||||
private @Nullable MappedLegacyBlockItem getMappedBlockItem(int id, int data) {
|
public int handleBlockId(final int rawId) {
|
||||||
MappedLegacyBlockItem mapping = replacementData.get(Block.toRawId(id, data));
|
final int id = Block.getId(rawId);
|
||||||
return mapping != null || data == 0 ? mapping : replacementData.get(Block.rawById(id));
|
final int data = Block.getData(rawId);
|
||||||
|
|
||||||
|
final Block mappedBlock = handleBlock(id, data);
|
||||||
|
if (mappedBlock == null) return rawId;
|
||||||
|
|
||||||
|
return Block.toRawId(mappedBlock.getId(), mappedBlock.getData());
|
||||||
}
|
}
|
||||||
|
|
||||||
private @Nullable MappedLegacyBlockItem getMappedBlockItem(int rawId) {
|
public void handleChunk(Chunk chunk) {
|
||||||
MappedLegacyBlockItem mapping = replacementData.get(rawId);
|
|
||||||
return mapping != null ? mapping : replacementData.get(Block.rawByData(rawId));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void handleChunk(Chunk chunk) {
|
|
||||||
// Map Block Entities
|
// Map Block Entities
|
||||||
Map<Pos, CompoundTag> tags = new HashMap<>();
|
Map<Pos, CompoundTag> tags = new HashMap<>();
|
||||||
for (CompoundTag tag : chunk.getBlockEntities()) {
|
for (CompoundTag tag : chunk.getBlockEntities()) {
|
||||||
@ -349,6 +335,20 @@ public abstract class LegacyBlockItemRewriter<C extends ClientboundPacketType, S
|
|||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private @Nullable MappedLegacyBlockItem getMappedBlockItem(int id, int data) {
|
||||||
|
MappedLegacyBlockItem mapping = replacementData.get(Block.toRawId(id, data));
|
||||||
|
return mapping != null || data == 0 ? mapping : replacementData.get(Block.rawById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
private @Nullable MappedLegacyBlockItem getMappedBlockItem(int rawId) {
|
||||||
|
MappedLegacyBlockItem mapping = replacementData.get(rawId);
|
||||||
|
return mapping != null ? mapping : replacementData.get(Block.rawByData(rawId));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected JsonObject readMappingsFile(final String name) {
|
||||||
|
return BackwardsMappingDataLoader.INSTANCE.loadFromDataDir(name);
|
||||||
|
}
|
||||||
|
|
||||||
private static final class Pos {
|
private static final class Pos {
|
||||||
|
|
||||||
private final int x;
|
private final int x;
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren