use of com.sk89q.jnbt.IntTag in project FastAsyncWorldEdit by IntellectualSites.
the class BedBlockCompatibilityHandler method updateNBT.
@Override
public <B extends BlockStateHolder<B>> BlockStateHolder<?> updateNBT(B block, Map<String, Tag> values) {
Tag typeTag = values.get("color");
if (typeTag instanceof IntTag) {
String bedType = convertBedType(((IntTag) typeTag).getValue());
if (bedType != null) {
BlockType type = BlockTypes.get("minecraft:" + bedType);
if (type != null) {
BlockState state = type.getDefaultState();
Property<Direction> facingProp = type.getProperty("facing");
state = state.with(facingProp, block.getState(FACING_PROPERTY));
Property<Boolean> occupiedProp = type.getProperty("occupied");
state = state.with(occupiedProp, false);
Property<String> partProp = type.getProperty("part");
state = state.with(partProp, block.getState(PART_PROPERTY));
values.remove("color");
return state;
}
}
}
return block;
}
use of com.sk89q.jnbt.IntTag in project FastAsyncWorldEdit by IntellectualSites.
the class FlowerPotCompatibilityHandler method updateNBT.
@Override
public <B extends BlockStateHolder<B>> BlockStateHolder<?> updateNBT(B block, Map<String, Tag> values) {
Tag item = values.get("Item");
if (item instanceof StringTag) {
String id = ((StringTag) item).getValue();
if (id.isEmpty()) {
return BlockTypes.FLOWER_POT.getDefaultState();
}
int data = 0;
Tag dataTag = values.get("Data");
if (dataTag instanceof IntTag) {
data = ((IntTag) dataTag).getValue();
}
BlockState newState = convertLegacyBlockType(id, data);
if (newState != null) {
values.clear();
return newState;
}
}
return block;
}
Aggregations