3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-26 02:50:06 +01:00

fix: try parsing special block data before blindly applying NBT

Dieser Commit ist enthalten in:
Pierre Maurice Schwang 2024-12-23 21:18:37 +01:00
Ursprung 9f4be9ef04
Commit bc63779de0
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 37E613079F3E5BB9

Datei anzeigen

@ -48,13 +48,13 @@ import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.extent.inventory.BlockBag; import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.internal.registry.InputParser; import com.sk89q.worldedit.internal.registry.InputParser;
import com.sk89q.worldedit.internal.util.DeprecationUtil;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.util.HandSide; import com.sk89q.worldedit.util.HandSide;
import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockCategories;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
@ -538,13 +538,7 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
//FAWE end //FAWE end
} }
if (nbt != null) { if (DeprecationUtil.isSign(blockType)) {
BaseBlock result = blockStates.size() > 0 ? state.toBaseBlock(nbt) : new BlanketBaseBlock(state, nbt);
return validate(context, result);
}
if (blockType == BlockTypes.SIGN || blockType == BlockTypes.WALL_SIGN
|| BlockCategories.SIGNS.contains(blockType)) {
// Allow special sign text syntax // Allow special sign text syntax
String[] text = new String[4]; String[] text = new String[4];
text[0] = blockAndExtraData.length > 1 ? blockAndExtraData[1] : ""; text[0] = blockAndExtraData.length > 1 ? blockAndExtraData[1] : "";
@ -552,10 +546,11 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
text[2] = blockAndExtraData.length > 3 ? blockAndExtraData[3] : ""; text[2] = blockAndExtraData.length > 3 ? blockAndExtraData[3] : "";
text[3] = blockAndExtraData.length > 4 ? blockAndExtraData[4] : ""; text[3] = blockAndExtraData.length > 4 ? blockAndExtraData[4] : "";
return validate(context, new SignBlock(state, text)); return validate(context, new SignBlock(state, text));
} else if (blockType == BlockTypes.SPAWNER) { } else if (blockType == BlockTypes.SPAWNER && (blockAndExtraData.length > 1 || nbt != null)) {
// Allow setting mob spawn type // Allow setting mob spawn type
String mobName;
if (blockAndExtraData.length > 1) { if (blockAndExtraData.length > 1) {
String mobName = blockAndExtraData[1]; mobName = blockAndExtraData[1];
EntityType ent = EntityTypes.get(mobName.toLowerCase(Locale.ROOT)); EntityType ent = EntityTypes.get(mobName.toLowerCase(Locale.ROOT));
if (ent == null) { if (ent == null) {
throw new NoMatchException(Caption.of("worldedit.error.unknown-entity", TextComponent.of(mobName))); throw new NoMatchException(Caption.of("worldedit.error.unknown-entity", TextComponent.of(mobName)));
@ -564,14 +559,13 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
if (!worldEdit.getPlatformManager().queryCapability(Capability.USER_COMMANDS).isValidMobType(mobName)) { if (!worldEdit.getPlatformManager().queryCapability(Capability.USER_COMMANDS).isValidMobType(mobName)) {
throw new NoMatchException(Caption.of("worldedit.error.unknown-mob", TextComponent.of(mobName))); throw new NoMatchException(Caption.of("worldedit.error.unknown-mob", TextComponent.of(mobName)));
} }
return validate(context, new MobSpawnerBlock(state, mobName));
} else { } else {
//noinspection ConstantConditions mobName = EntityTypes.PIG.id();
return validate(context, new MobSpawnerBlock(state, EntityTypes.PIG.id()));
} }
} else if (blockType == BlockTypes.PLAYER_HEAD || blockType == BlockTypes.PLAYER_WALL_HEAD) { return validate(context, new MobSpawnerBlock(state, mobName));
} else if ((blockType == BlockTypes.PLAYER_HEAD || blockType == BlockTypes.PLAYER_WALL_HEAD) && (blockAndExtraData.length > 1 || nbt != null)) {
// allow setting type/player/rotation // allow setting type/player/rotation
if (blockAndExtraData.length <= 1) { if (blockAndExtraData.length == 1) {
return validate(context, new SkullBlock(state)); return validate(context, new SkullBlock(state));
} }
@ -580,12 +574,14 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
return validate(context, new SkullBlock(state, type.replace(" ", "_"))); // valid MC usernames return validate(context, new SkullBlock(state, type.replace(" ", "_"))); // valid MC usernames
} else { } else {
//FAWE start //FAWE start
nbt = state.getNbtData(); if (nbt == null) {
nbt = state.getNbtData();
}
BaseBlock result; BaseBlock result;
if (nbt != null) { if (nbt != null) {
result = blockStates.size() > 0 ? state.toBaseBlock(nbt) : new BlanketBaseBlock(state, nbt); result = !blockStates.isEmpty() ? state.toBaseBlock(nbt) : new BlanketBaseBlock(state, nbt);
} else { } else {
result = blockStates.size() > 0 ? new BaseBlock(state) : state.toBaseBlock(); result = !blockStates.isEmpty() ? new BaseBlock(state) : state.toBaseBlock();
} }
return validate(context, result); return validate(context, result);
//FAWE end //FAWE end