use of com.sk89q.worldedit.world.block.BaseBlock in project FastAsyncWorldEdit by IntellectualSites.
the class RandomStatePatternParser method parseFromInput.
@Override
public Pattern parseFromInput(String input, ParserContext context) throws InputParseException {
if (!input.startsWith("*")) {
return null;
}
boolean wasFuzzy = context.isPreferringWildcard();
context.setPreferringWildcard(true);
BaseBlock block = worldEdit.getBlockFactory().parseFromInput(input.substring(1), context);
context.setPreferringWildcard(wasFuzzy);
if (block.getStates().size() == block.getBlockType().getPropertyMap().size()) {
// they requested random with *, but didn't leave any states empty - simplify
return block;
} else if (block.toImmutableState() instanceof FuzzyBlockState) {
return new RandomStatePattern((FuzzyBlockState) block.toImmutableState());
} else {
// only should happen if parseLogic changes
return null;
}
}
use of com.sk89q.worldedit.world.block.BaseBlock in project FastAsyncWorldEdit by IntellectualSites.
the class Int2BaseBlockMap method containsValue.
@Override
public boolean containsValue(Object v) {
BaseBlock block = (BaseBlock) v;
int internalId = optimizedInternalId(block);
if (!BlockStateIdAccess.isValidInternalId(internalId)) {
return uncommonMap.containsValue(block);
}
return commonMap.containsValue(internalId);
}
use of com.sk89q.worldedit.world.block.BaseBlock in project FastAsyncWorldEdit by IntellectualSites.
the class Int2BaseBlockMap method put.
@Override
public BaseBlock put(int key, BaseBlock value) {
int internalId = optimizedInternalId(value);
if (!BlockStateIdAccess.isValidInternalId(internalId)) {
BaseBlock old = uncommonMap.put(key, value);
if (old == null) {
// ensure common doesn't have the entry too
int oldId = commonMap.remove(key);
return assumeAsBlock(oldId);
}
return old;
}
int oldId = commonMap.put(key, internalId);
return assumeAsBlock(oldId);
}
use of com.sk89q.worldedit.world.block.BaseBlock in project FastAsyncWorldEdit by IntellectualSites.
the class ForgePlayer method sendFakeBlock.
@Override
public <B extends BlockStateHolder<B>> void sendFakeBlock(BlockVector3 pos, B block) {
World world = getWorld();
if (!(world instanceof ForgeWorld)) {
return;
}
BlockPos loc = ForgeAdapter.toBlockPos(pos);
if (block == null) {
final SChangeBlockPacket packetOut = new SChangeBlockPacket(((ForgeWorld) world).getWorld(), loc);
player.connection.sendPacket(packetOut);
} else {
final SChangeBlockPacket packetOut = new SChangeBlockPacket();
PacketBuffer buf = new PacketBuffer(Unpooled.buffer());
buf.writeBlockPos(loc);
buf.writeVarInt(Block.getStateId(ForgeAdapter.adapt(block.toImmutableState())));
try {
packetOut.readPacketData(buf);
} catch (IOException e) {
return;
}
player.connection.sendPacket(packetOut);
if (block instanceof BaseBlock && block.getBlockType().equals(BlockTypes.STRUCTURE_BLOCK)) {
final BaseBlock baseBlock = (BaseBlock) block;
final CompoundTag nbtData = baseBlock.getNbtData();
if (nbtData != null) {
player.connection.sendPacket(new SUpdateTileEntityPacket(new BlockPos(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ()), STRUCTURE_BLOCK_PACKET_ID, NBTConverter.toNative(nbtData)));
}
}
}
}
use of com.sk89q.worldedit.world.block.BaseBlock in project FastAsyncWorldEdit by IntellectualSites.
the class WaterloggedRemover method applyBlock.
@Override
public BaseBlock applyBlock(BlockVector3 position) {
BaseBlock block = getExtent().getFullBlock(position);
// FAWE start - remap
BlockState newState = remap[block.getOrdinal()];
if (newState != null) {
return newState.toBaseBlock(block.getNbtData());
}
// FAWE end
return BlockTypes.AIR.getDefaultState().toBaseBlock();
}
Aggregations