Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-05 19:10:07 +01:00
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.platform.Capability;
|
||||
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.io.ResourceLoader;
|
||||
import com.sk89q.worldedit.world.DataFixer;
|
||||
@ -81,10 +82,6 @@ public final class LegacyMapper {
|
||||
private LegacyMapper() {
|
||||
}
|
||||
|
||||
public final static LegacyMapper getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to load the data from file.
|
||||
*
|
||||
@ -110,33 +107,53 @@ public final class LegacyMapper {
|
||||
|
||||
for (Map.Entry<String, String> blockEntry : dataFile.blocks.entrySet()) {
|
||||
String id = blockEntry.getKey();
|
||||
Integer combinedId = getCombinedId(blockEntry.getKey());
|
||||
final String value = blockEntry.getValue();
|
||||
blockEntries.put(id, value);
|
||||
BlockState blockState = null;
|
||||
BlockFactory blockFactory = WorldEdit.getInstance().getBlockFactory();
|
||||
|
||||
if (fixer != null) {
|
||||
try {
|
||||
String newEntry = fixer.fixUp(DataFixer.FixTypes.BLOCK_STATE, value, 1631);
|
||||
blockState = blockFactory.parseFromInput(newEntry, parserContext).toImmutableState();
|
||||
} catch (InputParseException e) {
|
||||
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();
|
||||
if (fixer != null) {
|
||||
try {
|
||||
String newEntry = fixer.fixUp(DataFixer.FixTypes.BLOCK_STATE, value, 1631);
|
||||
blockState = blockFactory.parseFromInput(newEntry, parserContext).toImmutableState();
|
||||
} catch (InputParseException f) {
|
||||
}
|
||||
}
|
||||
// if it's still null, the fixer was unavailable or failed
|
||||
if (blockState == null) {
|
||||
try {
|
||||
blockState = blockFactory.parseFromInput(value, parserContext).toImmutableState();
|
||||
} catch (InputParseException f) {
|
||||
}
|
||||
}
|
||||
// if it's still null, both fixer and default failed
|
||||
if (blockState == null) {
|
||||
log.warn("Unknown block: " + value);
|
||||
} else {
|
||||
// it's not null so one of them succeeded, now use it
|
||||
blockToStringMap.put(blockState, id);
|
||||
stringToBlockMap.put(id, blockState);
|
||||
}
|
||||
}
|
||||
// if it's still null, the fixer was unavailable or failed
|
||||
if (blockState == null) {
|
||||
try {
|
||||
blockState = blockFactory.parseFromInput(value, parserContext).toImmutableState();
|
||||
} catch (InputParseException e) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
// if it's still null, both fixer and default failed
|
||||
if (blockState == null) {
|
||||
log.warn("Unknown block: " + value);
|
||||
} else {
|
||||
// it's not null so one of them succeeded, now use it
|
||||
blockToStringMap.put(blockState, id);
|
||||
stringToBlockMap.put(id, blockState);
|
||||
}
|
||||
}
|
||||
|
||||
for (Map.Entry<String, String> itemEntry : dataFile.items.entrySet()) {
|
||||
@ -267,7 +284,11 @@ public final class LegacyMapper {
|
||||
@Deprecated
|
||||
public int[] getLegacyFromBlock(BlockState 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"})
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren