@Override public String toString() { return getId(); }
switch (string.toLowerCase()) { case "white": return BlockTypes.WHITE_WOOL.getId(); case "black": return BlockTypes.BLACK_WOOL.getId(); case "blue": return BlockTypes.BLUE_WOOL.getId(); case "brown": return BlockTypes.BROWN_WOOL.getId(); case "cyan": return BlockTypes.CYAN_WOOL.getId(); case "gray": case "grey": return BlockTypes.GRAY_WOOL.getId(); case "green": return BlockTypes.GREEN_WOOL.getId(); case "light_blue": case "lightblue": return BlockTypes.LIGHT_BLUE_WOOL.getId(); case "light_gray": case "light_grey": case "lightgray": case "lightgrey": return BlockTypes.LIGHT_GRAY_WOOL.getId(); case "lime": return BlockTypes.LIME_WOOL.getId(); case "magenta": return BlockTypes.MAGENTA_WOOL.getId(); case "orange":
/** * Create a Bukkit Material form a WorldEdit BlockType * * @param blockType The WorldEdit BlockType * @return The Bukkit Material */ public static Material adapt(BlockType blockType) { checkNotNull(blockType); if (!blockType.getId().startsWith("minecraft:")) { throw new IllegalArgumentException("Bukkit only supports Minecraft blocks"); } return Material.getMaterial(blockType.getId().substring(10).toUpperCase()); }
public static BlockType register(final BlockType block) { return BlockType.REGISTRY.register(block.getId(), block); }
default String getAsString() { if (getStates().isEmpty()) { return this.getBlockType().getId(); } else { String properties = getStates().entrySet().stream().map(entry -> entry.getKey().getName() + "=" + entry.getValue().toString().toLowerCase()).collect(Collectors.joining( ",")); return this.getBlockType().getId() + "[" + properties + "]"; } } }
@Nullable @Override public String getName(BlockType blockType) { BundledBlockData.BlockEntry blockEntry = BundledBlockData.getInstance().findById(blockType.getId()); return blockEntry != null ? blockEntry.localizedName : null; }
/** * Checks equality between a WorldEdit BlockType and a Bukkit Material * * @param blockType The WorldEdit BlockType * @param type The Bukkit Material * @return If they are equal */ public static boolean equals(BlockType blockType, Material type) { return Objects.equals(blockType.getId(), type.getKey().toString()); }
@Nullable @Override public String getName(BlockType blockType) { return Block.REGISTRY.getObject(new ResourceLocation(blockType.getId())).getLocalizedName(); }
@Nullable @Override public BlockMaterial getMaterial(BlockType blockType) { return new PassthroughBlockMaterial(BundledBlockData.getInstance().getMaterialById(blockType.getId())); }
@SuppressWarnings("WeakerAccess") protected BlockState getBlockState(BlockStateHolder<?> block) { if (block instanceof com.sk89q.worldedit.world.block.BlockState) { BlockState state = Sponge.getRegistry().getType(BlockType.class, block.getBlockType().getId()).orElse(BlockTypes.AIR).getDefaultState(); for (Map.Entry<Property<?>, Object> entry : block.getStates().entrySet()) { // TODO Convert across states } return state; } else { throw new UnsupportedOperationException("Missing Sponge adapter for WorldEdit!"); } }
@Override public Map<String, ? extends Property<?>> getProperties(BlockType blockType) { Map<String, Property<?>> map = new TreeMap<>(); Collection<IProperty<?>> propertyKeys = Block.getBlockFromName(blockType.getId()) .getDefaultState() .getPropertyKeys(); for (IProperty<?> key : propertyKeys) { map.put(key.getName(), ForgeAdapter.adaptProperty(key)); } return map; }
@Override public BlockMaterial getMaterial(BlockType blockType) { return materialMap.computeIfAbsent(Block.getBlockFromName(blockType.getId()).getDefaultState().getMaterial(), m -> new ForgeBlockMaterial(m, super.getMaterial(blockType))); }
/** * Gets the name of this block, or the ID if the name cannot be found. * * @return The name, or ID */ public String getName() { String name = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getBlockRegistry().getName(this); if (name == null) { return getId(); } else { return name; } }
&& !config.allowedDataCycleBlocks.contains(block.getBlockType().getId())) { player.printError("You are not permitted to cycle the data value of that block."); return true;
structureTag.put("ignoreEntities", new ByteTag((byte) 1)); structureTag.put("showboundingbox", new ByteTag((byte) 1)); structureTag.put("id", new StringTag(BlockTypes.STRUCTURE_BLOCK.getId()));
Actor actor = context.requireActor(); if (actor != null && !actor.hasPermission("worldedit.anyblock") && worldEdit.getConfiguration().disallowedBlocks.contains(blockType.getId())) { throw new DisallowedUsageException("You are not allowed to use '" + input + "'");
c.getAmount() / (double) size * 100, name, c.getID().getBlockType().getId());
BlockPos pos = new BlockPos(x, y, z); IBlockState old = chunk.getBlockState(pos); Block mcBlock = Block.getBlockFromName(block.getBlockType().getId()); IBlockState newState = mcBlock.getDefaultState(); Map<Property<?>, Object> states = block.getStates();
blockState = getBlockStateWith(blockState, property, value); } catch (IllegalArgumentException e) { throw new InvalidFormatException("Invalid block state for " + blockState.getBlockType().getId() + ", " + property.getName() + ": " + value);
@Override public String getTypeId() { return type.getId(); }