@Override public boolean equals(Object obj) { if (!(obj instanceof BlockState)) { return false; } return equalsFuzzy((BlockState) obj); }
/** * Checks if the type is the same, and if the matched states are the same. * * @param o other block * @return true if equal */ @Override public boolean equalsFuzzy(BlockStateHolder<?> o) { return this.blockState.equalsFuzzy(o); }
/** * Checks whether the type ID and data value are equal. */ @Override public boolean equals(Object o) { if (!(o instanceof BaseBlock)) { if (!hasNbtData() && o instanceof BlockStateHolder) { return Objects.equals(toImmutableState(), ((BlockStateHolder<?>) o).toImmutableState()); } return false; } final BaseBlock otherBlock = (BaseBlock) o; return this.blockState.equalsFuzzy(otherBlock.blockState) && Objects.equals(getNbtData(), otherBlock.getNbtData()); }
@Override public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 location, B block) throws WorldEditException { if (!enabled) { return super.setBlock(location, block); } BlockState existing = getBlock(location); PlacementPriority priority = getPlacementPriority(block); PlacementPriority srcPriority = getPlacementPriority(existing); if (srcPriority != PlacementPriority.FIRST) { BaseBlock replacement = (block.getBlockType().getMaterial().isAir() ? block : BlockTypes.AIR.getDefaultState()).toBaseBlock(); switch (srcPriority) { case FINAL: stages.get(PlacementPriority.CLEAR_FINAL).add(location, replacement); break; case LATE: stages.get(PlacementPriority.CLEAR_LATE).add(location, replacement); break; case LAST: stages.get(PlacementPriority.CLEAR_LAST).add(location, replacement); break; } if (block.getBlockType().getMaterial().isAir()) { return !existing.equalsFuzzy(block); } } stages.get(priority).add(location, block); return !existing.equalsFuzzy(block); }