@Override public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate) { BlockStateDelegate blockStateDelegate = new BlockStateDelegate(); if (GlowTree.newInstance(type, ThreadLocalRandom.current(), blockStateDelegate) .generate(loc)) { List<BlockState> blockStates = new ArrayList<>(blockStateDelegate.getBlockStates()); StructureGrowEvent growEvent = new StructureGrowEvent(loc, type, false, null, blockStates); EventFactory.getInstance().callEvent(growEvent); if (!growEvent.isCancelled()) { for (BlockState state : blockStates) { state.update(true); if (delegate != null) { delegate.setTypeIdAndData(state.getX(), state.getY(), state.getZ(), state .getTypeId(), state.getRawData()); } } return true; } } return false; }
@Override public int getTypeId() { return base.getTypeId(); }
@SuppressWarnings("deprecation") public void addPlacedBlock(Block placeBlock, BlockState replacedBlock) { this.placedBlocks.add(placeBlock); if (replacedBlock != null) { if (replacedBlock.getData() instanceof Directional) { this.breakedBlockFace.put(replacedBlock.getBlock(), ((Directional) replacedBlock.getData()).getFacing()); } this.breakedBlockTypes.put(replacedBlock.getBlock(), replacedBlock.getTypeId()); this.breakedBlockData.put(replacedBlock.getBlock(), replacedBlock.getData().getData()); this.breakedBlocks.add(replacedBlock.getBlock()); } }
@SuppressWarnings("deprecation") public void addPlacedBlock(Block placeBlock, BlockState replacedBlock) { this.placedBlocks.add(placeBlock); if (replacedBlock != null) { if (replacedBlock.getData() instanceof Directional) { this.breakedBlockFace.put(replacedBlock.getBlock(), ((Directional) replacedBlock.getData()).getFacing()); } this.breakedBlockTypes.put(replacedBlock.getBlock(), replacedBlock.getTypeId()); this.breakedBlockData.put(replacedBlock.getBlock(), replacedBlock.getData().getData()); this.breakedBlocks.add(replacedBlock.getBlock()); } }
@SuppressWarnings("deprecation") public void addPlacedUnbreakableBlock(Block placed, BlockState replaced) { this.placedUnbreakableBlocks.add(placed); if (replaced != null) { if (replaced.getData() instanceof Directional) { this.breakedBlockFace.put(replaced.getBlock(), ((Directional) replaced.getData()).getFacing()); } this.breakedBlockTypes.put(replaced.getBlock(), replaced.getTypeId()); this.breakedBlockData.put(replaced.getBlock(), replaced.getData().getData()); this.breakedBlocks.add(replaced.getBlock()); if (replaced.getData() instanceof Redstone) { this.breakedBlockPower.put(placed, ((Redstone) replaced.getData()).isPowered()); } } }
@SuppressWarnings("deprecation") public void addPlacedUnbreakableBlock(Block placed, BlockState replaced) { this.placedUnbreakableBlocks.add(placed); if (replaced != null) { if (replaced.getData() instanceof Directional) { this.breakedBlockFace.put(replaced.getBlock(), ((Directional) replaced.getData()).getFacing()); } this.breakedBlockTypes.put(replaced.getBlock(), replaced.getTypeId()); this.breakedBlockData.put(replaced.getBlock(), replaced.getData().getData()); this.breakedBlocks.add(replaced.getBlock()); if (replaced.getData() instanceof Redstone) { this.breakedBlockPower.put(placed, ((Redstone) replaced.getData()).isPowered()); } } }
/** * @param state */ public GriefBlock(BlockState state) { super(state.getX(), state.getY(), state.getZ(), state.getWorld().getName()); this.type = new BlockTypeEntry(state.getTypeId(), state.getRawData()); this.empty = true; }
/** * @param state */ public TranslocationBlock(BlockState state) { super(state.getX(), state.getY(), state.getZ(), state.getWorld().getName()); this.type = new BlockTypeEntry(state.getTypeId(), state.getRawData()); this.empty = true; }
if (state.getTypeId() > 0) { if (!breakingFieldChecks(player, block, existingField, event)) { event.setCancelled(true);