Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-09-06 16:12:51 +02:00
[Forge] Make DefaultBlockParser behave more like vanilla.
Dieser Commit ist enthalten in:
Ursprung
5a42a8ddb4
Commit
e42107557e
@ -55,12 +55,37 @@ class DefaultBlockParser extends InputParser<BaseBlock> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBlock parseFromInput(String input, ParserContext context) throws InputParseException {
|
public BaseBlock parseFromInput(String input, ParserContext context)
|
||||||
// TODO: Rewrite this entire method to use BaseBlocks and ignore BlockType, as well as to properly handle mod:name IDs
|
throws InputParseException {
|
||||||
|
// TODO: Rewrite this entire method to use BaseBlocks and ignore
|
||||||
|
// BlockType, as well as to properly handle mod:name IDs
|
||||||
|
|
||||||
BlockType blockType;
|
String originalInput = input;
|
||||||
input = input.replace("_", " ");
|
input = input.replace("_", " ");
|
||||||
input = input.replace(";", "|");
|
input = input.replace(";", "|");
|
||||||
|
Exception suppressed = null;
|
||||||
|
try {
|
||||||
|
BaseBlock modified = parseLogic(input, context);
|
||||||
|
if (modified != null) {
|
||||||
|
return modified;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
suppressed = e;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return parseLogic(originalInput, context);
|
||||||
|
} catch (Exception e) {
|
||||||
|
if (suppressed != null) {
|
||||||
|
e.addSuppressed(suppressed);
|
||||||
|
}
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private BaseBlock parseLogic(String input, ParserContext context)
|
||||||
|
throws InputParseException, NoMatchException,
|
||||||
|
DisallowedUsageException {
|
||||||
|
BlockType blockType;
|
||||||
String[] blockAndExtraData = input.split("\\|");
|
String[] blockAndExtraData = input.split("\\|");
|
||||||
String[] blockLocator = blockAndExtraData[0].split(":", 3);
|
String[] blockLocator = blockAndExtraData[0].split(":", 3);
|
||||||
String[] typeAndData;
|
String[] typeAndData;
|
||||||
@ -118,12 +143,12 @@ class DefaultBlockParser extends InputParser<BaseBlock> {
|
|||||||
blockType = BlockType.lookup(testId);
|
blockType = BlockType.lookup(testId);
|
||||||
if (blockType == null) {
|
if (blockType == null) {
|
||||||
int t = worldEdit.getServer().resolveItem(testId);
|
int t = worldEdit.getServer().resolveItem(testId);
|
||||||
if (t > 0) {
|
if (t >= 0) {
|
||||||
blockType = BlockType.fromID(t); // Could be null
|
blockType = BlockType.fromID(t); // Could be null
|
||||||
blockId = t;
|
blockId = t;
|
||||||
} else if (blockLocator.length == 2) { // Block IDs in MC 1.7 and above use mod:name
|
} else if (blockLocator.length == 2) { // Block IDs in MC 1.7 and above use mod:name
|
||||||
t = worldEdit.getServer().resolveItem(blockAndExtraData[0]);
|
t = worldEdit.getServer().resolveItem(blockAndExtraData[0]);
|
||||||
if (t > 0) {
|
if (t >= 0) {
|
||||||
blockType = BlockType.fromID(t); // Could be null
|
blockType = BlockType.fromID(t); // Could be null
|
||||||
blockId = t;
|
blockId = t;
|
||||||
typeAndData = new String[] { blockAndExtraData[0] };
|
typeAndData = new String[] { blockAndExtraData[0] };
|
||||||
|
@ -69,7 +69,7 @@ class ForgePlatform extends AbstractPlatform implements MultiUserPlatform {
|
|||||||
|
|
||||||
int index = name.indexOf(':');
|
int index = name.indexOf(':');
|
||||||
|
|
||||||
if (index != -1 && index != 0 && index != name.length() - 1) {
|
if (index != 0 && index != name.length() - 1) {
|
||||||
Block block = Block.getBlockFromName(name);
|
Block block = Block.getBlockFromName(name);
|
||||||
if (block != null) {
|
if (block != null) {
|
||||||
return Block.getIdFromBlock(block);
|
return Block.getIdFromBlock(block);
|
||||||
@ -87,7 +87,7 @@ class ForgePlatform extends AbstractPlatform implements MultiUserPlatform {
|
|||||||
}
|
}
|
||||||
if (item.getUnlocalizedName().equalsIgnoreCase(name)) return Item.getIdFromItem(item);
|
if (item.getUnlocalizedName().equalsIgnoreCase(name)) return Item.getIdFromItem(item);
|
||||||
}
|
}
|
||||||
return 0;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren