/** * Returns whether the EntityAIBase should begin execution. */ public boolean shouldExecute() { if (!super.shouldExecute()) { return false; } else if (!this.theEntity.worldObj.getGameRules().getBoolean("mobGriefing")) { return false; } else { BlockDoor blockdoor = this.doorBlock; return !BlockDoor.isOpen(this.theEntity.worldObj, this.doorPosition); } }
/** * Returns whether an in-progress EntityAIBase should continue executing */ public boolean continueExecuting() { double d0 = this.theEntity.getDistanceSq(this.doorPosition); boolean flag; if (this.breakingTime <= 240) { BlockDoor blockdoor = this.doorBlock; if (!BlockDoor.isOpen(this.theEntity.worldObj, this.doorPosition) && d0 < 4.0D) { flag = true; return flag; } } flag = false; return flag; }
public static void placeDoor(World worldIn, BlockPos pos, EnumFacing facing, Block door) { BlockPos blockpos = pos.offset(facing.rotateY()); BlockPos blockpos1 = pos.offset(facing.rotateYCCW()); int i = (worldIn.getBlockState(blockpos1).getBlock().isNormalCube() ? 1 : 0) + (worldIn.getBlockState(blockpos1.up()).getBlock().isNormalCube() ? 1 : 0); int j = (worldIn.getBlockState(blockpos).getBlock().isNormalCube() ? 1 : 0) + (worldIn.getBlockState(blockpos.up()).getBlock().isNormalCube() ? 1 : 0); boolean flag = worldIn.getBlockState(blockpos1).getBlock() == door || worldIn.getBlockState(blockpos1.up()).getBlock() == door; boolean flag1 = worldIn.getBlockState(blockpos).getBlock() == door || worldIn.getBlockState(blockpos.up()).getBlock() == door; boolean flag2 = false; if (flag && !flag1 || j > i) { flag2 = true; } BlockPos blockpos2 = pos.up(); IBlockState iblockstate = door.getDefaultState().withProperty(BlockDoor.FACING, facing).withProperty(BlockDoor.HINGE, flag2 ? BlockDoor.EnumHingePosition.RIGHT : BlockDoor.EnumHingePosition.LEFT); worldIn.setBlockState(pos, iblockstate.withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.LOWER), 2); worldIn.setBlockState(blockpos2, iblockstate.withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER), 2); worldIn.notifyNeighborsOfStateChange(pos, door); worldIn.notifyNeighborsOfStateChange(blockpos2, door); }
private void addToNewDoorsList(BlockPos doorBlock) { EnumFacing enumfacing = BlockDoor.getFacing(this.worldObj, doorBlock); EnumFacing enumfacing1 = enumfacing.getOpposite(); int i = this.countBlocksCanSeeSky(doorBlock, enumfacing, 5); int j = this.countBlocksCanSeeSky(doorBlock, enumfacing1, i + 1); if (i != j) { this.newDoors.add(new VillageDoorInfo(doorBlock, i < j ? enumfacing : enumfacing1, this.tickCounter)); } }
private void setDungeon() { this.floor = Blocks.planks.getDefaultState(); this.exterior = Blocks.cobblestone.getDefaultState(); this.wall = Blocks.cobblestone.getDefaultState(); this.light = Blocks.torch.getDefaultState(); this.goal = Blocks.gold_block.getDefaultState(); this.moat = Blocks.lava.getDefaultState(); this.moatContainer = Blocks.cobblestone.getDefaultState(); this.doorUpper = Blocks.oak_door.getDefaultState().withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER); this.doorLower = Blocks.oak_door.getDefaultState().withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.LOWER); this.stairs = Blocks.stone_stairs.getDefaultState(); this.stairsPlatform = Blocks.cobblestone.getDefaultState(); this.ladder = Blocks.ladder.getDefaultState(); this.puzzleDoorUpper = Blocks.iron_door.getDefaultState().withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER); this.puzzleDoorLower = Blocks.iron_door.getDefaultState().withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.LOWER); this.trigger = Blocks.lever.getDefaultState(); this.platform = Blocks.bookshelf.getDefaultState(); this.hint = Blocks.gold_ore.getDefaultState(); }
private void setPyramid() { this.floor = Blocks.red_sandstone.getDefaultState(); this.exterior = Blocks.sandstone.getDefaultState(); this.wall = Blocks.sandstone.getDefaultState(); this.light = Blocks.torch.getDefaultState(); this.goal = Blocks.diamond_block.getDefaultState(); this.moat = Blocks.lava.getDefaultState(); this.moatContainer = Blocks.sandstone.getDefaultState(); this.doorUpper = Blocks.acacia_door.getDefaultState().withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER); this.doorLower = Blocks.acacia_door.getDefaultState().withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.LOWER); this.stairs = Blocks.sandstone_stairs.getDefaultState(); this.stairsPlatform = Blocks.sandstone.getDefaultState(); this.ladder = Blocks.ladder.getDefaultState(); this.puzzleDoorUpper = Blocks.iron_door.getDefaultState().withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER); this.puzzleDoorLower = Blocks.iron_door.getDefaultState().withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.LOWER); this.trigger = Blocks.lever.getDefaultState(); this.platform = Blocks.red_sandstone.getDefaultState(); this.hint = Blocks.diamond_ore.getDefaultState(); }
private void setIgloo() { this.floor = Blocks.snow.getDefaultState(); this.exterior = Blocks.snow.getDefaultState(); this.wall = Blocks.packed_ice.getDefaultState(); this.light = Blocks.torch.getDefaultState(); this.goal = Blocks.redstone_block.getDefaultState(); this.moat = Blocks.water.getDefaultState(); this.moatContainer = Blocks.glowstone.getDefaultState(); this.doorUpper = Blocks.spruce_door.getDefaultState().withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER); this.doorLower = Blocks.spruce_door.getDefaultState().withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.LOWER); this.stairs = Blocks.spruce_stairs.getDefaultState(); this.stairsPlatform = Blocks.packed_ice.getDefaultState(); this.ladder = Blocks.ladder.getDefaultState(); this.puzzleDoorUpper = Blocks.iron_door.getDefaultState().withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER); this.puzzleDoorLower = Blocks.iron_door.getDefaultState().withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.LOWER); this.trigger = Blocks.lever.getDefaultState(); this.platform = Blocks.snow.getDefaultState(); this.hint = Blocks.redstone_ore.getDefaultState(); }
/** * Returns whether the EntityAIBase should begin execution. */ public boolean shouldExecute() { if (!super.shouldExecute()) { return false; } else if (!this.theEntity.world.getGameRules().getBoolean("mobGriefing")) { return false; } else { BlockDoor blockdoor = this.doorBlock; return !BlockDoor.isOpen(this.theEntity.world, this.doorPosition); } }
/** * Returns whether an in-progress EntityAIBase should continue executing */ public boolean continueExecuting() { double d0 = this.theEntity.getDistanceSq(this.doorPosition); boolean flag; if (this.breakingTime <= 240) { BlockDoor blockdoor = this.doorBlock; if (!BlockDoor.isOpen(this.theEntity.world, this.doorPosition) && d0 < 4.0D) { flag = true; return flag; } } flag = false; return flag; }
@Test public void test_spell_block_can_place_door() throws Exception { // Given: mc().setBlock(lowerDoorPos, Blocks.AIR); mc().setBlock(upperDoorPos, Blocks.AIR); // When: mc().executeCommand( "/lua spell.pos = Vec3.from(%s,%s,%s); spell.block=Blocks.get('wooden_door'):withData({half='lower'}); spell:move('up'); spell.block=Blocks.get('wooden_door'):withData({half='upper'}); print('ok')", posP1.getX(), posP1.getY(), posP1.getZ()); // Then: ServerLog4jEvent act = mc().waitFor(ServerLog4jEvent.class); assertThat(act.getMessage()).isEqualTo("ok"); IBlockState actLower = mc().getBlock(lowerDoorPos); assertThat(actLower).isA(Blocks.OAK_DOOR).property(BlockDoor.HALF) .isEqualTo(BlockDoor.EnumDoorHalf.LOWER); IBlockState actUpper = mc().getBlock(upperDoorPos); assertThat(actUpper).isA(Blocks.OAK_DOOR).property(BlockDoor.HALF) .isEqualTo(BlockDoor.EnumDoorHalf.UPPER); }
private void setDungeon() { this.floor = Blocks.PLANKS.getDefaultState(); this.exterior = Blocks.COBBLESTONE.getDefaultState(); this.wall = Blocks.COBBLESTONE.getDefaultState(); this.light = Blocks.TORCH.getDefaultState(); this.goal = Blocks.GOLD_BLOCK.getDefaultState(); this.moat = Blocks.LAVA.getDefaultState(); this.moatContainer = Blocks.COBBLESTONE.getDefaultState(); this.doorUpper = Blocks.OAK_DOOR.getDefaultState().withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER); this.doorLower = Blocks.OAK_DOOR.getDefaultState().withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.LOWER); this.stairs = Blocks.STONE_STAIRS.getDefaultState(); this.stairsPlatform = Blocks.COBBLESTONE.getDefaultState(); this.ladder = Blocks.LADDER.getDefaultState(); this.puzzleDoorUpper = Blocks.IRON_DOOR.getDefaultState().withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER); this.puzzleDoorLower = Blocks.IRON_DOOR.getDefaultState().withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.LOWER); this.trigger = Blocks.LEVER.getDefaultState(); this.platform = Blocks.BOOKSHELF.getDefaultState(); this.hint = Blocks.GOLD_ORE.getDefaultState(); }
private void setPyramid() { this.floor = Blocks.RED_SANDSTONE.getDefaultState(); this.exterior = Blocks.SANDSTONE.getDefaultState(); this.wall = Blocks.SANDSTONE.getDefaultState(); this.light = Blocks.TORCH.getDefaultState(); this.goal = Blocks.DIAMOND_BLOCK.getDefaultState(); this.moat = Blocks.LAVA.getDefaultState(); this.moatContainer = Blocks.SANDSTONE.getDefaultState(); this.doorUpper = Blocks.ACACIA_DOOR.getDefaultState().withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER); this.doorLower = Blocks.ACACIA_DOOR.getDefaultState().withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.LOWER); this.stairs = Blocks.SANDSTONE_STAIRS.getDefaultState(); this.stairsPlatform = Blocks.SANDSTONE.getDefaultState(); this.ladder = Blocks.LADDER.getDefaultState(); this.puzzleDoorUpper = Blocks.IRON_DOOR.getDefaultState().withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER); this.puzzleDoorLower = Blocks.IRON_DOOR.getDefaultState().withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.LOWER); this.trigger = Blocks.LEVER.getDefaultState(); this.platform = Blocks.RED_SANDSTONE.getDefaultState(); this.hint = Blocks.DIAMOND_ORE.getDefaultState(); }
private void setIgloo() { this.floor = Blocks.SNOW.getDefaultState(); this.exterior = Blocks.SNOW.getDefaultState(); this.wall = Blocks.PACKED_ICE.getDefaultState(); this.light = Blocks.TORCH.getDefaultState(); this.goal = Blocks.REDSTONE_BLOCK.getDefaultState(); this.moat = Blocks.WATER.getDefaultState(); this.moatContainer = Blocks.GLOWSTONE.getDefaultState(); this.doorUpper = Blocks.SPRUCE_DOOR.getDefaultState().withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER); this.doorLower = Blocks.SPRUCE_DOOR.getDefaultState().withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.LOWER); this.stairs = Blocks.SPRUCE_STAIRS.getDefaultState(); this.stairsPlatform = Blocks.PACKED_ICE.getDefaultState(); this.ladder = Blocks.LADDER.getDefaultState(); this.puzzleDoorUpper = Blocks.IRON_DOOR.getDefaultState().withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER); this.puzzleDoorLower = Blocks.IRON_DOOR.getDefaultState().withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.LOWER); this.trigger = Blocks.LEVER.getDefaultState(); this.platform = Blocks.SNOW.getDefaultState(); this.hint = Blocks.REDSTONE_ORE.getDefaultState(); }
@SubscribeEvent public void playerLeftClick(PlayerInteractEvent.LeftClickBlock event) { if (!event.getEntityPlayer().capabilities.isCreativeMode && event.getWorld().getBlockState(event.getPos()).getBlock() instanceof BlockDoor && event.getWorld().getBlockState(event.getPos()).getMaterial() == Material.WOOD) { event.getWorld().playSound(null, event.getPos(), SoundEvents.BLOCK_METAL_PLACE, SoundCategory.BLOCKS, 1, 1); event.getWorld().playSound(null, event.getPos(), SoundEvents.BLOCK_WOOD_PLACE, SoundCategory.BLOCKS, 1, 1); event.getWorld().playSound(null, event.getPos(), SoundEvents.BLOCK_WOOD_PLACE, SoundCategory.BLOCKS, 1, 1); event.getWorld().playSound(null, event.getPos(), SoundEvents.BLOCK_WOOD_PLACE, SoundCategory.BLOCKS, 1, 1); } if (!event.getEntityPlayer().capabilities.isCreativeMode && event.getWorld().getBlockState(event.getPos()).getBlock() instanceof BlockDoor && event.getWorld().getBlockState(event.getPos()).getMaterial() == Material.IRON) { event.getWorld().playSound(null, event.getPos(), SoundEvents.BLOCK_METAL_PLACE, SoundCategory.BLOCKS, 1, 1); event.getWorld().playSound(null, event.getPos(), SoundEvents.BLOCK_METAL_PLACE, SoundCategory.BLOCKS, 1, 1); event.getWorld().playSound(null, event.getPos(), SoundEvents.BLOCK_METAL_PLACE, SoundCategory.BLOCKS, 1, 1); event.getWorld().playSound(null, event.getPos(), SoundEvents.BLOCK_METAL_PLACE, SoundCategory.BLOCKS, 1, 1); event.getWorld().playSound(null, event.getPos(), SoundEvents.BLOCK_METAL_PLACE, SoundCategory.BLOCKS, 1, 1); event.getWorld().playSound(null, event.getPos(), SoundEvents.BLOCK_METAL_PLACE, SoundCategory.BLOCKS, 1, 1); } }
private static void findFuels() { afuels = new ArrayList<>(); Set<Item> efuels = excludedFuels(); for (ItemStack item : ItemList.items) { Block block = Block.getBlockFromItem(item.getItem()); if (block instanceof BlockDoor) { continue; } if (efuels.contains(item.getItem())) { continue; } int burnTime = TileEntityFurnace.getItemBurnTime(item); if (burnTime > 0) { afuels.add(new FuelPair(item.copy(), burnTime)); } } }
public static void onBlockActivatedHook(BlockDoor door, World world, BlockPos pos, IBlockState state, EntityPlayer player, MainOrOffHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { if (player.isSneaking()) return; state = world.getBlockState(pos); BlockPos doorBase = state.getValue(BlockDoor.HALF) == BlockDoor.EnumDoorHalf.LOWER ? pos : pos.down(); state = world.getBlockState(doorBase); for (EnumFacing facing : EnumFacing.values()) { if (facing == EnumFacing.DOWN || facing == EnumFacing.UP) continue; BlockPos newPos = doorBase.offset(facing); IBlockState newState = world.getBlockState(newPos); if (newState == null) continue; if (newState.getBlock() != door) continue; if ((boolean)newState.getValue(BlockDoor.OPEN) == (boolean)state.getValue(BlockDoor.OPEN)) continue; if (newState.getValue(BlockDoor.HALF) != state.getValue(BlockDoor.HALF)) continue; //newState.getBlock().onBlockActivated(world, newPos, newState, player, hand, stack, side, hitX, hitY, hitZ); newState = newState.cycleProperty(BlockDoor.OPEN); world.setBlockState(newPos, newState, 2); world.markBlockRangeForRenderUpdate(newPos, newPos); //world.playAuxSFXAtEntity(player, ((Boolean)newState.getValue(BlockDoor.OPEN)).booleanValue() ? 1003 : 1006, newPos, 0); world.playAuxSFXAtEntity(player, ((Boolean)newState.getValue(BlockDoor.OPEN)).booleanValue() ? 1005 : 1011, newPos, 0); } }
public static void onNeighborBlockChangeHook(BlockDoor door, boolean powered, IBlockState state, World world, BlockPos pos, Block block, BlockPos pos2) { for (EnumFacing facing : EnumFacing.values()) { if (facing == EnumFacing.DOWN || facing == EnumFacing.UP) continue; BlockPos newPos = pos.offset(facing); IBlockState newState = world.getBlockState(newPos); if (newState == null) continue; if (newState.getBlock() != door) continue; //if ((boolean)newState.getValue(OPEN) == (boolean)state.getValue(OPEN)) continue; if (newState.getValue(BlockDoor.HALF) != state.getValue(BlockDoor.HALF)) continue; world.setBlockState(newPos, state.withProperty(BlockDoor.OPEN, Boolean.valueOf(powered)), 2); world.markBlockRangeForRenderUpdate(newPos, newPos); //world.playAuxSFXAtEntity((EntityPlayer)null, powered ? 1003 : 1006, newPos, 0); world.playAuxSFXAtEntity((EntityPlayer)null, powered ? 1005 : 1011, newPos, 0); } }
@Override public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if (player.getHeldItemMainhand().getItem() == ModItems.WoodenKeyblade || player.getHeldItemMainhand().getItem() == ModItems.WoodenStick || player.getHeldItemMainhand().getItem() == ModItems.DreamSword) return EnumActionResult.PASS; if (world.getBlockState(pos).getBlock() instanceof BlockDoor) { SoundEvent sound; PlayerStatsCapability.IPlayerStats STATS = player.getCapability(ModCapabilities.PLAYER_STATS, null); if ((!STATS.getRecharge()) || player.getCapability(ModCapabilities.CHEAT_MODE, null).getCheatMode()) { if (world.getBlockState(pos).getValue(BlockDoor.HALF) == EnumDoorHalf.UPPER) { world.setBlockState(pos.down(), world.getBlockState(pos.down()).withProperty(BlockDoor.OPEN, !world.getBlockState(pos.down()).getValue(BlockDoor.OPEN))); sound = world.getBlockState(pos.down()).getValue(BlockDoor.OPEN) ? SoundEvents.BLOCK_IRON_DOOR_CLOSE : SoundEvents.BLOCK_IRON_DOOR_OPEN; world.playSound(player, pos, sound, SoundCategory.BLOCKS, 1.0f, 1.0f); return EnumActionResult.SUCCESS; } else { world.setBlockState(pos, world.getBlockState(pos).withProperty(BlockDoor.OPEN, !world.getBlockState(pos).getValue(BlockDoor.OPEN))); sound = world.getBlockState(pos).getValue(BlockDoor.OPEN) ? SoundEvents.BLOCK_IRON_DOOR_CLOSE : SoundEvents.BLOCK_IRON_DOOR_OPEN; world.playSound(player, pos, sound, SoundCategory.BLOCKS, 1.0f, 1.0f); return EnumActionResult.SUCCESS; } } } return super.onItemUse(player, world, pos, hand, facing, hitX, hitY, hitZ); }
private static void findFuels() { afuels = new ArrayList<>(); Set<Item> efuels = excludedFuels(); for (ItemStack item : ItemList.items) { Block block = Block.getBlockFromItem(item.getItem()); if (block instanceof BlockDoor) { continue; } if (efuels.contains(item.getItem())) { continue; } int burnTime = TileEntityBrickOven.getItemBurnTime(item); if (burnTime > 0) { afuels.add(new FuelPair(item.copy(), burnTime)); } } }
private static void findFuels() { afuels = new ArrayList<>(); Set<Item> efuels = excludedFuels(); for (ItemStack item : ItemList.items) { Block block = Block.getBlockFromItem(item.getItem()); if (block instanceof BlockDoor) { continue; } if (efuels.contains(item.getItem())) { continue; } int burnTime = TileEntitySmelter.getItemBurnTime(item); if (burnTime > 0) { afuels.add(new FurnaceRecipeHandler.FuelPair(item.copy(), burnTime)); } } }
private static void findFuels() { afuels = new ArrayList<>(); Set<Item> efuels = excludedFuels(); for (ItemStack item : ItemList.items) { Block block = Block.getBlockFromItem(item.getItem()); if (block instanceof BlockDoor) { continue; } if (efuels.contains(item.getItem())) { continue; } int burnTime = TileEntityKiln.getItemBurnTime(item); if (burnTime > 0) { afuels.add(new FurnaceRecipeHandler.FuelPair(item.copy(), burnTime)); } } }