use of org.bukkit.material.PistonBaseMaterial in project MagicPlugin by elBukkit.
the class ConstructBatch method constructBlock.
@SuppressWarnings("deprecation")
public boolean constructBlock(int dx, int dy, int dz) {
// Special-case hackiness..
if (limitYAxis && minOrientDimension != null && dy < -minOrientDimension)
return true;
if (limitYAxis && maxOrientDimension != null && dy > maxOrientDimension)
return true;
if (bounds != null) {
if (dx > bounds.getX() || dy > bounds.getY() || dz > bounds.getZ())
return true;
if (dx < -bounds.getX() || dy < -bounds.getY() || dz < -bounds.getZ())
return true;
}
// Initial range checks, we skip everything if this is not sane.
int x = center.getBlockX() + dx;
int y = center.getBlockY() + dy;
int z = center.getBlockZ() + dz;
if (y < 0 || y > center.getWorld().getMaxHeight())
return true;
// Make sure the block is loaded.
Block block = center.getWorld().getBlockAt(x, y, z);
if (!block.getChunk().isLoaded()) {
block.getChunk().load();
return false;
}
// Destructibility and permission checks
if (!spell.isDestructible(block)) {
return true;
}
if (replace != null && replace.size() > 0) {
com.elmakers.mine.bukkit.block.MaterialAndData check = new com.elmakers.mine.bukkit.block.MaterialAndData(block);
if (!replace.contains(check.getKey()) && !replace.contains(check.getWildDataKey())) {
return true;
}
}
// Prepare material brush, it may update
// given the current target (clone, replicate)
MaterialBrush brush = spell.getBrush();
brush.update(mage, block.getLocation());
if (brush.isErase()) {
if (!spell.hasBreakPermission(block)) {
return true;
}
} else {
if (!spell.hasBuildPermission(block)) {
return true;
}
}
// Check for power mode.
if (power) {
Material material = block.getType();
BlockState blockState = block.getState();
MaterialData data = blockState.getData();
boolean powerBlock = false;
if (data instanceof Button) {
Button powerData = (Button) data;
registerForUndo(block);
powerData.setPowered(!powerData.isPowered());
powerBlock = true;
} else if (data instanceof Lever) {
Lever powerData = (Lever) data;
registerForUndo(block);
powerData.setPowered(!powerData.isPowered());
powerBlock = true;
} else if (data instanceof PistonBaseMaterial) {
PistonBaseMaterial powerData = (PistonBaseMaterial) data;
registerForUndo(block);
powerData.setPowered(!powerData.isPowered());
powerBlock = true;
} else if (data instanceof PoweredRail) {
PoweredRail powerData = (PoweredRail) data;
registerForUndo(block);
powerData.setPowered(!powerData.isPowered());
powerBlock = true;
} else if (data instanceof RedstoneWire) {
RedstoneWire wireData = (RedstoneWire) data;
registerForUndo(block);
wireData.setData((byte) (15 - wireData.getData()));
powerBlock = true;
} else if (material == Material.REDSTONE_BLOCK) {
registerForUndo(block);
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, material.getId());
controller.getRedstoneReplacement().modify(block, applyPhysics);
} else if (material == Material.REDSTONE_TORCH_OFF) {
registerForUndo(block);
block.setType(Material.REDSTONE_TORCH_ON);
} else if (material == Material.REDSTONE_TORCH_ON) {
registerForUndo(block);
block.setType(Material.REDSTONE_TORCH_OFF);
} else if (material == Material.TNT) {
registerForUndo(block);
block.setType(Material.AIR);
// Kaboomy time!
registerForUndo(block.getLocation().getWorld().spawnEntity(block.getLocation(), EntityType.PRIMED_TNT));
}
if (powerBlock) {
blockState.update();
}
return true;
}
// Make sure the brush is ready, it may need to load chunks.
if (!brush.isReady()) {
brush.prepare();
return false;
}
// Postpone attachable blocks to a second batch
if (attachables.testMaterialAndData(brush) || attachablesWall.testMaterialAndData(brush) || attachablesDouble.testMaterialAndData(brush)) {
BlockData attachBlock = new BlockData(block);
attachBlock.updateFrom(brush);
attachedBlockMap.put(attachBlock.getId(), attachBlock);
attachedBlockList.add(attachBlock);
return true;
}
if (delayed.testMaterialAndData(brush)) {
BlockData delayBlock = new BlockData(block);
delayBlock.updateFrom(brush);
delayedBlocks.add(delayBlock);
return true;
}
modifyWith(block, brush);
return true;
}
use of org.bukkit.material.PistonBaseMaterial in project Glowstone by GlowstoneMC.
the class BlockPiston method onRedstoneUpdate.
@Override
public void onRedstoneUpdate(GlowBlock me) {
PistonBaseMaterial piston = (PistonBaseMaterial) me.getState().getData();
BlockFace pistonBlockFace = piston.getFacing();
int rawFace = BlockDirectional.getRawFace(pistonBlockFace);
BlockActionMessage message = new BlockActionMessage(me.getX(), me.getY(), me.getZ(), me.isBlockIndirectlyPowered() ? 0 : 1, rawFace, me.getType().getId());
GlowChunk chunk = me.getChunk();
GlowChunk.Key chunkKey = GlowChunk.Key.of(chunk.getX(), chunk.getZ());
GlowWorld world = me.getWorld();
if (me.isBlockIndirectlyPowered() && !isPistonExtended(me)) {
List<Block> blocksToMove = new ArrayList<>();
List<Block> blocksToBreak = new ArrayList<>();
boolean allowMovement = addBlock(me, pistonBlockFace, me.getRelative(pistonBlockFace), pistonBlockFace.getOppositeFace(), blocksToMove, blocksToBreak);
if (!allowMovement) {
return;
}
BlockPistonExtendEvent event = EventFactory.getInstance().callEvent(new BlockPistonExtendEvent(me, blocksToMove, pistonBlockFace));
if (event.isCancelled()) {
return;
}
world.getRawPlayers().stream().filter(player -> player.canSeeChunk(chunkKey)).forEach(player -> player.getSession().send(message));
world.playSound(me.getLocation(), Sound.BLOCK_PISTON_EXTEND, SoundCategory.BLOCKS, 0.5f, 0.75f);
// extended state for piston base
me.setData((byte) (me.getData() | 0x08));
performMovement(pistonBlockFace, blocksToMove, blocksToBreak);
// set piston head block when extended
setType(me.getRelative(pistonBlockFace), Material.MOVING_PISTON, sticky ? me.getData() | 0x08 : rawFace);
return;
}
if (!isPistonExtended(me)) {
return;
}
List<Block> blocksToMove = new ArrayList<>();
List<Block> blocksToBreak = new ArrayList<>();
if (sticky) {
addBlock(me, pistonBlockFace.getOppositeFace(), me.getRelative(pistonBlockFace, 2), pistonBlockFace.getOppositeFace(), blocksToMove, blocksToBreak);
}
BlockPistonRetractEvent event = EventFactory.getInstance().callEvent(new BlockPistonRetractEvent(me, blocksToMove, pistonBlockFace));
if (event.isCancelled()) {
return;
}
world.getRawPlayers().stream().filter(player -> player.canSeeChunk(chunkKey)).forEach(player -> player.getSession().send(message));
world.playSound(me.getLocation(), Sound.BLOCK_PISTON_CONTRACT, SoundCategory.BLOCKS, 0.5f, 0.75f);
// normal state for piston
setType(me, me.getType(), me.getData() & ~0x08);
if (sticky && blocksToMove.size() > 0) {
performMovement(pistonBlockFace.getOppositeFace(), blocksToMove, blocksToBreak);
} else {
// remove piston head
me.getRelative(pistonBlockFace).setTypeIdAndData(0, (byte) 0, true);
}
}
use of org.bukkit.material.PistonBaseMaterial in project MagicPlugin by elBukkit.
the class PowerBlockAction method perform.
@SuppressWarnings("deprecation")
@Override
public SpellResult perform(CastContext context) {
Block block = context.getTargetBlock();
if (!context.hasBuildPermission(block)) {
return SpellResult.INSUFFICIENT_PERMISSION;
}
if (!context.isDestructible(block)) {
return SpellResult.NO_TARGET;
}
context.getUndoList().setApplyPhysics(true);
Material material = block.getType();
BlockState blockState = block.getState();
MaterialData data = blockState.getData();
MageController controller = context.getController();
boolean powerBlock = false;
if (data instanceof Button) {
Button powerData = (Button) data;
context.registerForUndo(block);
powerData.setPowered(!powerData.isPowered());
powerBlock = true;
} else if (data instanceof Lever) {
Lever powerData = (Lever) data;
context.registerForUndo(block);
powerData.setPowered(!powerData.isPowered());
powerBlock = true;
} else if (data instanceof PistonBaseMaterial) {
PistonBaseMaterial powerData = (PistonBaseMaterial) data;
context.registerForUndo(block);
powerData.setPowered(!powerData.isPowered());
powerBlock = true;
} else if (data instanceof PoweredRail) {
PoweredRail powerData = (PoweredRail) data;
context.registerForUndo(block);
powerData.setPowered(!powerData.isPowered());
powerBlock = true;
} else if (data instanceof RedstoneWire) {
RedstoneWire wireData = (RedstoneWire) data;
context.registerForUndo(block);
wireData.setData((byte) (15 - wireData.getData()));
powerBlock = true;
} else if (material == Material.REDSTONE_BLOCK) {
context.registerForUndo(block);
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, material.getId());
controller.getRedstoneReplacement().modify(block, applyPhysics);
} else if (material == Material.REDSTONE_TORCH_OFF) {
context.registerForUndo(block);
block.setType(Material.REDSTONE_TORCH_ON);
} else if (material == Material.REDSTONE_TORCH_ON) {
context.registerForUndo(block);
block.setType(Material.REDSTONE_TORCH_OFF);
} else if (material == Material.TNT) {
context.registerForUndo(block);
block.setType(Material.AIR);
// Kaboomy time!
context.registerForUndo(block.getLocation().getWorld().spawnEntity(block.getLocation(), EntityType.PRIMED_TNT));
}
if (powerBlock) {
blockState.update();
}
return SpellResult.CAST;
}
use of org.bukkit.material.PistonBaseMaterial in project Glowstone by GlowstoneMC.
the class GlowJungleTemple method generate.
@Override
public boolean generate(World world, Random random, StructureBoundingBox genBoundingBox, BlockStateDelegate delegate) {
if (!super.generate(world, random, boundingBox, delegate)) {
return false;
}
adjustHorizPos(world);
boundingBox.offset(new Vector(0, -4, 0));
StructureBuilder builder = new StructureBuilder(world, this, genBoundingBox, delegate);
Map<StructureMaterial, Integer> stones = new HashMap<>();
builder.addRandomMaterial(stones, 4, Material.COBBLESTONE, 0);
builder.addRandomMaterial(stones, 6, Material.MOSSY_COBBLESTONE, 0);
RandomItemsContent chestContent = getChestContent();
RandomItemsContent dispenserContent = new RandomItemsContent();
dispenserContent.addItem(new RandomAmountItem(Material.ARROW, 2, 7), 30);
// 1st floor
builder.fillWithRandomMaterial(new Vector(0, 0, 0), new Vector(11, 0, 14), random, stones);
builder.fillWithRandomMaterial(new Vector(0, 1, 0), new Vector(11, 3, 0), random, stones);
builder.fillWithRandomMaterial(new Vector(11, 1, 1), new Vector(11, 3, 13), random, stones);
builder.fillWithRandomMaterial(new Vector(0, 1, 1), new Vector(0, 3, 13), random, stones);
builder.fillWithRandomMaterial(new Vector(0, 1, 14), new Vector(11, 3, 14), random, stones);
builder.fillWithRandomMaterial(new Vector(0, 4, 0), new Vector(11, 4, 14), random, stones);
Stairs entranceStairs = new Stairs(Material.COBBLESTONE_STAIRS);
entranceStairs.setFacingDirection(getRelativeFacing(BlockFace.SOUTH));
builder.fill(new Vector(4, 4, 0), new Vector(7, 4, 0), entranceStairs.getItemType(), entranceStairs);
builder.fill(new Vector(1, 1, 1), new Vector(10, 3, 13), Material.AIR);
builder.fill(new Vector(5, 4, 7), new Vector(6, 4, 9), Material.AIR);
// 2nd floor
builder.fillWithRandomMaterial(new Vector(2, 5, 2), new Vector(9, 6, 2), random, stones);
builder.fillWithRandomMaterial(new Vector(9, 5, 3), new Vector(9, 6, 11), random, stones);
builder.fillWithRandomMaterial(new Vector(2, 5, 12), new Vector(9, 6, 12), random, stones);
builder.fillWithRandomMaterial(new Vector(2, 5, 3), new Vector(2, 6, 11), random, stones);
builder.fillWithRandomMaterial(new Vector(1, 7, 1), new Vector(10, 7, 13), random, stones);
builder.fill(new Vector(3, 5, 3), new Vector(8, 6, 11), Material.AIR);
builder.fill(new Vector(4, 7, 6), new Vector(7, 7, 9), Material.AIR);
builder.fill(new Vector(5, 5, 2), new Vector(6, 6, 2), Material.AIR);
builder.fill(new Vector(5, 6, 12), new Vector(6, 6, 12), Material.AIR);
// 3rd floor
builder.fillWithRandomMaterial(new Vector(1, 8, 1), new Vector(10, 9, 1), random, stones);
builder.fillWithRandomMaterial(new Vector(10, 8, 2), new Vector(10, 9, 12), random, stones);
builder.fillWithRandomMaterial(new Vector(1, 8, 13), new Vector(10, 9, 13), random, stones);
builder.fillWithRandomMaterial(new Vector(1, 8, 2), new Vector(1, 9, 12), random, stones);
builder.fill(new Vector(2, 8, 2), new Vector(9, 9, 12), Material.AIR);
builder.fill(new Vector(5, 9, 1), new Vector(6, 9, 1), Material.AIR);
builder.fill(new Vector(5, 9, 13), new Vector(6, 9, 13), Material.AIR);
builder.setBlock(new Vector(10, 9, 5), Material.AIR);
builder.setBlock(new Vector(10, 9, 9), Material.AIR);
builder.setBlock(new Vector(1, 9, 5), Material.AIR);
builder.setBlock(new Vector(1, 9, 9), Material.AIR);
// roof
builder.fillWithRandomMaterial(new Vector(1, 10, 1), new Vector(10, 10, 4), random, stones);
builder.fillWithRandomMaterial(new Vector(8, 10, 5), new Vector(10, 10, 9), random, stones);
builder.fillWithRandomMaterial(new Vector(1, 10, 5), new Vector(3, 10, 9), random, stones);
builder.fillWithRandomMaterial(new Vector(1, 10, 10), new Vector(10, 10, 13), random, stones);
builder.fillWithRandomMaterial(new Vector(3, 11, 3), new Vector(8, 11, 5), random, stones);
builder.fillWithRandomMaterial(new Vector(7, 11, 6), new Vector(8, 11, 8), random, stones);
builder.fillWithRandomMaterial(new Vector(3, 11, 6), new Vector(4, 11, 8), random, stones);
builder.fillWithRandomMaterial(new Vector(3, 11, 9), new Vector(8, 11, 11), random, stones);
builder.fillWithRandomMaterial(new Vector(4, 12, 4), new Vector(7, 12, 10), random, stones);
builder.fill(new Vector(4, 10, 5), new Vector(7, 10, 9), Material.AIR);
builder.fill(new Vector(5, 11, 6), new Vector(6, 11, 8), Material.AIR);
// outside walls decorations
builder.fillWithRandomMaterial(new Vector(2, 8, 0), new Vector(2, 9, 0), random, stones);
builder.fillWithRandomMaterial(new Vector(4, 8, 0), new Vector(4, 9, 0), random, stones);
builder.fillWithRandomMaterial(new Vector(7, 8, 0), new Vector(7, 9, 0), random, stones);
builder.fillWithRandomMaterial(new Vector(9, 8, 0), new Vector(9, 9, 0), random, stones);
builder.fillWithRandomMaterial(new Vector(5, 10, 0), new Vector(6, 10, 0), random, stones);
for (int i = 0; i < 6; i++) {
builder.fillWithRandomMaterial(new Vector(11, 8, 2 + (i << 1)), new Vector(11, 9, 2 + (i << 1)), random, stones);
builder.fillWithRandomMaterial(new Vector(0, 8, 2 + (i << 1)), new Vector(0, 9, 2 + (i << 1)), random, stones);
}
builder.setBlockWithRandomMaterial(new Vector(11, 10, 5), random, stones);
builder.setBlockWithRandomMaterial(new Vector(11, 10, 9), random, stones);
builder.setBlockWithRandomMaterial(new Vector(0, 10, 5), random, stones);
builder.setBlockWithRandomMaterial(new Vector(0, 10, 9), random, stones);
builder.fillWithRandomMaterial(new Vector(2, 8, 14), new Vector(2, 9, 14), random, stones);
builder.fillWithRandomMaterial(new Vector(4, 8, 14), new Vector(4, 9, 14), random, stones);
builder.fillWithRandomMaterial(new Vector(7, 8, 14), new Vector(7, 9, 14), random, stones);
builder.fillWithRandomMaterial(new Vector(9, 8, 14), new Vector(9, 9, 14), random, stones);
// roof decorations
builder.fillWithRandomMaterial(new Vector(2, 11, 2), new Vector(2, 13, 2), random, stones);
builder.fillWithRandomMaterial(new Vector(9, 11, 2), new Vector(9, 13, 2), random, stones);
builder.fillWithRandomMaterial(new Vector(9, 11, 12), new Vector(9, 13, 12), random, stones);
builder.fillWithRandomMaterial(new Vector(2, 11, 12), new Vector(2, 13, 12), random, stones);
builder.setBlockWithRandomMaterial(new Vector(4, 13, 4), random, stones);
builder.setBlockWithRandomMaterial(new Vector(7, 13, 4), random, stones);
builder.setBlockWithRandomMaterial(new Vector(7, 13, 10), random, stones);
builder.setBlockWithRandomMaterial(new Vector(4, 13, 10), random, stones);
Stairs roofStairsN = new Stairs(Material.COBBLESTONE_STAIRS);
roofStairsN.setFacingDirection(getRelativeFacing(BlockFace.SOUTH));
builder.fill(new Vector(5, 13, 6), new Vector(6, 13, 6), roofStairsN.getItemType(), roofStairsN);
builder.fillWithRandomMaterial(new Vector(5, 13, 7), new Vector(6, 13, 7), random, stones);
Stairs roofStairsS = new Stairs(Material.COBBLESTONE_STAIRS);
roofStairsS.setFacingDirection(getRelativeFacing(BlockFace.NORTH));
builder.fill(new Vector(5, 13, 8), new Vector(6, 13, 8), roofStairsS.getItemType(), roofStairsS);
// 1st floor inside
for (int i = 0; i < 6; i++) {
builder.fillWithRandomMaterial(new Vector(1, 3, 2 + (i << 1)), new Vector(3, 3, 2 + (i << 1)), random, stones);
}
for (int i = 0; i < 7; i++) {
builder.fillWithRandomMaterial(new Vector(1, 1, 1 + (i << 1)), new Vector(1, 2, 1 + (i << 1)), random, stones);
}
builder.setBlockWithRandomMaterial(new Vector(2, 2, 1), random, stones);
builder.setBlock(new Vector(3, 1, 1), Material.MOSSY_COBBLESTONE);
builder.fillWithRandomMaterial(new Vector(4, 2, 1), new Vector(5, 2, 1), random, stones);
builder.setBlockWithRandomMaterial(new Vector(6, 1, 1), random, stones);
builder.setBlockWithRandomMaterial(new Vector(6, 3, 1), random, stones);
builder.fillWithRandomMaterial(new Vector(7, 2, 1), new Vector(9, 2, 1), random, stones);
builder.setBlock(new Vector(8, 1, 1), Material.MOSSY_COBBLESTONE);
builder.fillWithRandomMaterial(new Vector(10, 1, 1), new Vector(10, 3, 7), random, stones);
builder.fillWithRandomMaterial(new Vector(9, 3, 1), new Vector(9, 3, 7), random, stones);
builder.setBlock(new Vector(9, 1, 2), Material.MOSSY_COBBLESTONE);
builder.setBlock(new Vector(9, 1, 4), Material.MOSSY_COBBLESTONE);
builder.setBlock(new Vector(8, 1, 5), Material.MOSSY_COBBLESTONE);
builder.fill(new Vector(7, 2, 5), new Vector(7, 3, 5), Material.MOSSY_COBBLESTONE);
builder.setBlock(new Vector(6, 1, 5), Material.MOSSY_COBBLESTONE);
builder.setBlockWithRandomMaterial(new Vector(6, 2, 5), random, stones);
builder.fill(new Vector(5, 2, 5), new Vector(5, 3, 5), Material.MOSSY_COBBLESTONE);
builder.setBlock(new Vector(4, 1, 5), Material.MOSSY_COBBLESTONE);
builder.fillWithRandomMaterial(new Vector(7, 1, 6), new Vector(7, 3, 11), random, stones);
builder.fillWithRandomMaterial(new Vector(4, 1, 6), new Vector(4, 3, 11), random, stones);
builder.fillWithRandomMaterial(new Vector(5, 3, 11), new Vector(6, 3, 11), random, stones);
builder.fillWithRandomMaterial(new Vector(8, 3, 11), new Vector(10, 3, 11), random, stones);
builder.fillWithRandomMaterial(new Vector(8, 1, 11), new Vector(10, 1, 11), random, stones);
builder.fillWithRandomMaterial(new Vector(5, 1, 8), new Vector(6, 1, 8), random, stones);
builder.fillWithRandomMaterial(new Vector(6, 1, 7), new Vector(6, 2, 7), random, stones);
builder.setBlockWithRandomMaterial(new Vector(5, 2, 7), random, stones);
builder.fillWithRandomMaterial(new Vector(6, 1, 6), new Vector(6, 3, 6), random, stones);
builder.fillWithRandomMaterial(new Vector(5, 2, 6), new Vector(5, 3, 6), random, stones);
builder.fillWithRandomMaterial(new Vector(8, 2, 6), new Vector(9, 2, 6), random, stones);
builder.setBlockWithRandomMaterial(new Vector(8, 3, 6), random, stones);
builder.fillWithRandomMaterial(new Vector(9, 1, 7), new Vector(9, 2, 7), random, stones);
builder.fillWithRandomMaterial(new Vector(8, 1, 7), new Vector(8, 3, 7), random, stones);
builder.fillWithRandomMaterial(new Vector(10, 1, 8), new Vector(10, 1, 10), random, stones);
builder.setBlock(new Vector(10, 2, 9), Material.MOSSY_COBBLESTONE);
builder.fillWithRandomMaterial(new Vector(8, 1, 8), new Vector(8, 1, 10), random, stones);
builder.fill(new Vector(8, 2, 11), new Vector(10, 2, 11), Material.CHISELED_STONE_BRICKS);
Lever lever = new Lever(Material.LEVER, // workaround for bukkit, can't set an attached BlockFace
(byte) 4);
lever.setFacingDirection(getRelativeFacing(BlockFace.SOUTH));
builder.fill(new Vector(8, 2, 12), new Vector(10, 2, 12), lever.getItemType(), lever);
if (!placedTrap1) {
placedTrap1 = builder.createRandomItemsContainer(new Vector(3, 2, 1), random, dispenserContent, new Dispenser(getRelativeFacing(BlockFace.SOUTH)), 2);
}
if (!placedTrap2) {
placedTrap2 = builder.createRandomItemsContainer(new Vector(9, 2, 3), random, dispenserContent, new Dispenser(getRelativeFacing(BlockFace.WEST)), 2);
}
Vine vine = new Vine(BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST);
builder.setBlock(new Vector(3, 2, 2), vine.getItemType(), vine);
builder.fill(new Vector(8, 2, 3), new Vector(8, 3, 3), vine.getItemType(), vine);
builder.fill(new Vector(2, 1, 8), new Vector(3, 1, 8), Material.TRIPWIRE);
TripwireHook hookE = new TripwireHook(getRelativeFacing(BlockFace.WEST));
hookE.setConnected(true);
builder.setBlock(new Vector(4, 1, 8), hookE.getItemType(), hookE);
TripwireHook hookW = new TripwireHook(getRelativeFacing(BlockFace.EAST));
hookW.setConnected(true);
builder.setBlock(new Vector(1, 1, 8), hookW.getItemType(), hookW);
builder.fill(new Vector(5, 1, 1), new Vector(5, 1, 7), Material.REDSTONE_WIRE);
builder.setBlock(new Vector(4, 1, 1), Material.REDSTONE_WIRE);
builder.fill(new Vector(7, 1, 2), new Vector(7, 1, 4), Material.TRIPWIRE);
TripwireHook hookN = new TripwireHook(getRelativeFacing(BlockFace.SOUTH));
hookN.setConnected(true);
builder.setBlock(new Vector(7, 1, 1), hookN.getItemType(), hookN);
TripwireHook hookS = new TripwireHook(getRelativeFacing(BlockFace.NORTH));
hookS.setConnected(true);
builder.setBlock(new Vector(7, 1, 5), hookS.getItemType(), hookS);
builder.fill(new Vector(8, 1, 6), new Vector(9, 1, 6), Material.REDSTONE_WIRE);
builder.setBlock(new Vector(9, 1, 5), Material.REDSTONE_WIRE);
builder.setBlock(new Vector(9, 2, 4), Material.REDSTONE_WIRE);
PistonBaseMaterial pistonE = new PistonBaseMaterial(Material.PISTON);
pistonE.setFacingDirection(getRelativeFacing(BlockFace.WEST));
builder.fill(new Vector(10, 2, 8), new Vector(10, 3, 8), pistonE.getItemType(), pistonE);
// TODO: 1.13 is this the right piston material??
PistonBaseMaterial pistonUp = new PistonBaseMaterial(Material.STICKY_PISTON);
pistonUp.setFacingDirection(BlockFace.UP);
builder.setBlock(new Vector(9, 2, 8), pistonUp.getItemType(), pistonUp);
builder.setBlock(new Vector(10, 3, 9), Material.REDSTONE_WIRE);
builder.fill(new Vector(8, 2, 9), new Vector(8, 2, 10), Material.REDSTONE_WIRE);
Diode repeater = new Diode(Material.REPEATER);
repeater.setDelay(1);
repeater.setFacingDirection(getRelativeFacing(BlockFace.SOUTH));
builder.setBlock(new Vector(10, 2, 10), repeater.getItemType(), repeater);
if (!placedMainChest) {
placedMainChest = builder.createRandomItemsContainer(new Vector(8, 1, 3), random, chestContent, new Chest(getRelativeFacing(BlockFace.WEST)), random.nextInt(5) + 2);
}
if (!placedHiddenChest) {
placedHiddenChest = builder.createRandomItemsContainer(new Vector(9, 1, 10), random, chestContent, new Chest(getRelativeFacing(BlockFace.NORTH)), random.nextInt(5) + 2);
}
// 2nd floor inside
for (int i = 0; i < 4; i++) {
Stairs stairsS = new Stairs(Material.COBBLESTONE_STAIRS);
stairsS.setFacingDirection(getRelativeFacing(BlockFace.NORTH));
builder.fill(new Vector(5, 4 - i, 6 + i), new Vector(6, 4 - i, 6 + i), stairsS.getItemType(), stairsS);
}
builder.fillWithRandomMaterial(new Vector(4, 5, 10), new Vector(7, 6, 10), random, stones);
builder.setBlockWithRandomMaterial(new Vector(4, 5, 9), random, stones);
builder.setBlockWithRandomMaterial(new Vector(7, 5, 9), random, stones);
for (int i = 0; i < 3; i++) {
Stairs leftStairs = new Stairs(Material.COBBLESTONE_STAIRS);
leftStairs.setFacingDirection(getRelativeFacing(BlockFace.SOUTH));
builder.setBlock(new Vector(7, 5 + i, 8 + i), leftStairs.getItemType(), leftStairs);
Stairs rightStairs = new Stairs(Material.COBBLESTONE_STAIRS);
rightStairs.setFacingDirection(getRelativeFacing(BlockFace.SOUTH));
builder.setBlock(new Vector(4, 5 + i, 8 + i), rightStairs.getItemType(), rightStairs);
}
// 3rd floor inside
builder.fillWithRandomMaterial(new Vector(5, 8, 5), new Vector(6, 8, 5), random, stones);
Stairs stairsE = new Stairs(Material.COBBLESTONE_STAIRS);
stairsE.setFacingDirection(getRelativeFacing(BlockFace.WEST));
builder.setBlock(new Vector(7, 8, 5), stairsE.getItemType(), stairsE);
Stairs stairsW = new Stairs(Material.COBBLESTONE_STAIRS);
stairsW.setFacingDirection(getRelativeFacing(BlockFace.EAST));
builder.setBlock(new Vector(4, 8, 5), stairsW.getItemType(), stairsW);
return true;
}
Aggregations