geforkt von Mirrors/FastAsyncWorldEdit
Fix legacy id conversion
Dieser Commit ist enthalten in:
Ursprung
b0208e06cd
Commit
39b60aa742
@ -33,6 +33,7 @@ import com.sk89q.worldedit.extension.input.InputParseException;
|
|||||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||||
import com.sk89q.worldedit.extension.platform.Capability;
|
import com.sk89q.worldedit.extension.platform.Capability;
|
||||||
import com.sk89q.worldedit.math.Vector3;
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
|
import com.sk89q.worldedit.registry.state.PropertyKey;
|
||||||
import com.sk89q.worldedit.util.gson.VectorAdapter;
|
import com.sk89q.worldedit.util.gson.VectorAdapter;
|
||||||
import com.sk89q.worldedit.util.io.ResourceLoader;
|
import com.sk89q.worldedit.util.io.ResourceLoader;
|
||||||
import com.sk89q.worldedit.world.DataFixer;
|
import com.sk89q.worldedit.world.DataFixer;
|
||||||
@ -81,10 +82,6 @@ public final class LegacyMapper {
|
|||||||
private LegacyMapper() {
|
private LegacyMapper() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public final static LegacyMapper getInstance() {
|
|
||||||
return INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempt to load the data from file.
|
* Attempt to load the data from file.
|
||||||
*
|
*
|
||||||
@ -110,23 +107,30 @@ public final class LegacyMapper {
|
|||||||
|
|
||||||
for (Map.Entry<String, String> blockEntry : dataFile.blocks.entrySet()) {
|
for (Map.Entry<String, String> blockEntry : dataFile.blocks.entrySet()) {
|
||||||
String id = blockEntry.getKey();
|
String id = blockEntry.getKey();
|
||||||
|
Integer combinedId = getCombinedId(blockEntry.getKey());
|
||||||
final String value = blockEntry.getValue();
|
final String value = blockEntry.getValue();
|
||||||
blockEntries.put(id, value);
|
blockEntries.put(id, value);
|
||||||
BlockState blockState = null;
|
BlockState blockState = null;
|
||||||
|
try {
|
||||||
|
blockState = BlockState.get(null, blockEntry.getValue());
|
||||||
|
BlockType type = blockState.getBlockType();
|
||||||
|
if (type.hasProperty(PropertyKey.WATERLOGGED)) {
|
||||||
|
blockState = blockState.with(PropertyKey.WATERLOGGED, false);
|
||||||
|
}
|
||||||
|
} catch (InputParseException e) {
|
||||||
BlockFactory blockFactory = WorldEdit.getInstance().getBlockFactory();
|
BlockFactory blockFactory = WorldEdit.getInstance().getBlockFactory();
|
||||||
|
|
||||||
if (fixer != null) {
|
if (fixer != null) {
|
||||||
try {
|
try {
|
||||||
String newEntry = fixer.fixUp(DataFixer.FixTypes.BLOCK_STATE, value, 1631);
|
String newEntry = fixer.fixUp(DataFixer.FixTypes.BLOCK_STATE, value, 1631);
|
||||||
blockState = blockFactory.parseFromInput(newEntry, parserContext).toImmutableState();
|
blockState = blockFactory.parseFromInput(newEntry, parserContext).toImmutableState();
|
||||||
} catch (InputParseException e) {
|
} catch (InputParseException f) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// if it's still null, the fixer was unavailable or failed
|
// if it's still null, the fixer was unavailable or failed
|
||||||
if (blockState == null) {
|
if (blockState == null) {
|
||||||
try {
|
try {
|
||||||
blockState = blockFactory.parseFromInput(value, parserContext).toImmutableState();
|
blockState = blockFactory.parseFromInput(value, parserContext).toImmutableState();
|
||||||
} catch (InputParseException e) {
|
} catch (InputParseException f) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// if it's still null, both fixer and default failed
|
// if it's still null, both fixer and default failed
|
||||||
@ -138,6 +142,19 @@ public final class LegacyMapper {
|
|||||||
stringToBlockMap.put(id, blockState);
|
stringToBlockMap.put(id, blockState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
blockArr[combinedId] = blockState.getInternalId();
|
||||||
|
blockStateToLegacyId4Data.put(blockState.getInternalId(), (Integer) combinedId);
|
||||||
|
blockStateToLegacyId4Data.putIfAbsent(blockState.getInternalBlockTypeId(), combinedId);
|
||||||
|
}
|
||||||
|
for (int id = 0; id < 256; id++) {
|
||||||
|
int combinedId = id << 4;
|
||||||
|
int base = blockArr[combinedId];
|
||||||
|
if (base != 0) {
|
||||||
|
for (int data = 0; data < 16; data++, combinedId++) {
|
||||||
|
if (blockArr[combinedId] == 0) blockArr[combinedId] = base;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (Map.Entry<String, String> itemEntry : dataFile.items.entrySet()) {
|
for (Map.Entry<String, String> itemEntry : dataFile.items.entrySet()) {
|
||||||
String id = itemEntry.getKey();
|
String id = itemEntry.getKey();
|
||||||
@ -267,7 +284,11 @@ public final class LegacyMapper {
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
public int[] getLegacyFromBlock(BlockState blockState) {
|
public int[] getLegacyFromBlock(BlockState blockState) {
|
||||||
Integer combinedId = getLegacyCombined(blockState);
|
Integer combinedId = getLegacyCombined(blockState);
|
||||||
return combinedId == null ? null : new int[]{combinedId >> 4, combinedId & 0xF};
|
return combinedId == null ? null : new int[] { combinedId >> 4, combinedId & 0xF };
|
||||||
|
}
|
||||||
|
|
||||||
|
public final static LegacyMapper getInstance() {
|
||||||
|
return INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({"MismatchedQueryAndUpdateOfCollection"})
|
@SuppressWarnings({"MismatchedQueryAndUpdateOfCollection"})
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren