/** * Get the list of possible {@link ExcavationTreasure|ExcavationTreasures} obtained from a given block. * * @param blockState The {@link BlockState} of the block to check. * @return the list of treasures that could be found */ protected static List<ExcavationTreasure> getTreasures(BlockState blockState) { String friendly = StringUtils.getFriendlyConfigBlockDataString(blockState.getBlockData()); if (TreasureConfig.getInstance().excavationMap.containsKey(friendly)) return TreasureConfig.getInstance().excavationMap.get(friendly); return new ArrayList<ExcavationTreasure>(); }
public MgBlockData(BlockState original, MinigamePlayer modifier){ location = original.getLocation(); state = original; blockData = state.getBlockData().getAsString(); if(modifier !=null)playerUUID = modifier.getUUID(); }
@Override public int getFakeData(final BlockCache blockCache, final World world, final int x, final int y, final int z) { final Block block = world.getBlockAt(x, y, z); final BlockState state = block.getState(); final BlockData blockData = state.getBlockData(); if (blockData instanceof EndPortalFrame) { return ((EndPortalFrame) blockData).hasEye() ? 0x4 : 0; } else { return 0; } }
@Override public int getFakeData(final BlockCache blockCache, final World world, final int x, final int y, final int z) { final Block block = world.getBlockAt(x, y, z); final BlockState state = block.getState(); final BlockData blockData = state.getBlockData(); if (blockData instanceof Openable) { return ((Openable) blockData).isOpen() ? 0x4 : 0; } else { return 0; } }
@Override public int getFakeData(final BlockCache blockCache, final World world, final int x, final int y, final int z) { final Block block = world.getBlockAt(x, y, z); final BlockState state = block.getState(); final BlockData blockData = state.getBlockData(); if (blockData instanceof Openable) { return ((Openable) blockData).isOpen() ? 0x4 : 0; } else { return 0; } }
@Override public double[] getShape(final BlockCache blockCache, final World world, final int x, final int y, final int z) { final Block block = world.getBlockAt(x, y, z); final BlockState state = block.getState(); final BlockData blockData = state.getBlockData(); if (blockData instanceof EndPortalFrame) { return ((EndPortalFrame) blockData).hasEye() ? new double[] {0.0, 0.0, 0.0, 1.0, 1.0, 1.0} : new double[] {0.0, 0.0, 0.0, 1.0, 0.8125, 1.0}; } else { return new double[] {0.0, 0.0, 0.0, 1.0, 1.0, 1.0}; } }
public static boolean isFullyGrown(BlockState blockState) { BlockData data = blockState.getBlockData(); if (data.getMaterial() == Material.CACTUS || data.getMaterial() == Material.SUGAR_CANE) return true; if (data instanceof Ageable) { Ageable ageable = (Ageable) data; return ageable.getAge() == ageable.getMaximumAge(); } return true; } }
/** * Check if a given block is a log * * @param blockState * The {@link BlockState} of the block to check * @return true if the block is a log, false otherwise */ public static boolean isLog(BlockState blockState) { if (ExperienceConfig.getInstance().doesBlockGiveSkillXP(PrimarySkillType.WOODCUTTING, blockState.getBlockData())) return true; return mcMMO.getModManager().isCustomLog(blockState); }
@Override public int getFakeData(final BlockCache blockCache, final World world, final int x, final int y, final int z) { final Block block = world.getBlockAt(x, y, z); final BlockState state = block.getState(); final BlockData blockData = state.getBlockData(); if (blockData instanceof Bisected) { final Bisected stairs = (Bisected) blockData; final Half half = stairs.getHalf(); //final Shape shape = stairs.getShape(); // TODO: Refine later, with sub shapes. switch (half) { case TOP: return 0x4; default: break; } } return 0; }
/** * Determine if a given block should be affected by Giga Drill Breaker * * @param blockState * The {@link BlockState} of the block to check * @return true if the block should affected by Giga Drill Breaker, false * otherwise */ public static boolean affectedByGigaDrillBreaker(BlockState blockState) { if (ExperienceConfig.getInstance().doesBlockGiveSkillXP(PrimarySkillType.EXCAVATION, blockState.getBlockData())) return true; return mcMMO.getModManager().isCustomExcavationBlock(blockState); }
/** * Determine if a given block should be affected by Green Terra * * @param blockState * The {@link BlockState} of the block to check * @return true if the block should affected by Green Terra, false otherwise */ public static boolean affectedByGreenTerra(BlockState blockState) { if (ExperienceConfig.getInstance().doesBlockGiveSkillXP(PrimarySkillType.HERBALISM, blockState.getBlockData())) { return true; } return mcMMO.getModManager().isCustomHerbalismBlock(blockState); }
@Override public double[] getShape(final BlockCache blockCache, final World world, final int x, final int y, final int z) { final Block block = world.getBlockAt(x, y, z); final BlockState state = block.getState(); final BlockData blockData = state.getBlockData(); if (blockData instanceof Directional) { switch (((Directional) blockData).getFacing()) { case WEST: return new double[] {minXZ, 0.0, 0.0, maxXZ, height, 1.0}; case EAST: return new double[] {minXZ, 0.0, 0.0, maxXZ, height, 1.0}; case NORTH: return new double[] {0.0, 0.0, minXZ, 1.0, height, maxXZ}; case SOUTH: return new double[] {0.0, 0.0, minXZ, 1.0, height, maxXZ}; default: break; } } return new double[] {0.0, 0.0, 0.0, 1.0, 1.0, 1.0}; }
@Override public double[] getShape(final BlockCache blockCache, final World world, final int x, final int y, final int z) { final Block block = world.getBlockAt(x, y, z); final BlockState state = block.getState(); final BlockData blockData = state.getBlockData(); if (blockData instanceof Slab) { final Slab slab = (Slab) blockData; switch (slab.getType()) { case BOTTOM: return new double[] {0.0, 0.0, 0.0, 1.0, 0.5, 1.0}; case TOP: return new double[] {0.0, 0.5, 0.0, 1.0, 1.0, 1.0}; case DOUBLE: break; default: break; } } return new double[] {0.0, 0.0, 0.0, 1.0, 1.0, 1.0}; }
public boolean blockCrackerCheck(BlockState blockState) { if (!RandomChanceUtil.isActivationSuccessful(SkillActivationType.ALWAYS_FIRES, SubSkillType.UNARMED_BLOCK_CRACKER, getPlayer())) { return false; } BlockData data = blockState.getBlockData(); switch (blockState.getType()) { case STONE_BRICKS: if (!Unarmed.blockCrackerSmoothBrick) { return false; } blockState.setType(Material.CRACKED_STONE_BRICKS); return true; default: return false; } }
/** * Determine if a given block should be affected by Super Breaker * * @param blockState * The {@link BlockState} of the block to check * @return true if the block should affected by Super Breaker, false * otherwise */ public static Boolean affectedBySuperBreaker(BlockState blockState) { if (ExperienceConfig.getInstance().doesBlockGiveSkillXP(PrimarySkillType.MINING, blockState.getBlockData())) return true; return isOre(blockState) || mcMMO.getModManager().isCustomMiningBlock(blockState); }
public RepairableBlock(BlockState state) { this.state = state; world = state.getWorld(); x = state.getX(); y = state.getY(); z = state.getZ(); data = state.getBlockData(); type = state.getType(); }
@Override public final BlockFace getCardinal() { final BlockData blockdata = this.getBlock().getState().getBlockData(); if(blockdata instanceof Directional) { return ((Directional) blockdata).getFacing().getOppositeFace(); } if(blockdata instanceof Rotatable) { BlockFace f = ((Rotatable) blockdata).getRotation().getOppositeFace(); f = MathUtil.straightUp(f); if (f == BlockFace.UP) { ByteCart.log.severe("ByteCart: Tilted sign found at " + this.getLocation() + ". Please straight it up in the axis of the track"); return null; } return f; } return null; }
public void repair() { if (getWorld().getBlockAt(getX(), getY(), getZ()).getState().getData() instanceof Bed) return; super.repair(); other.getBlock().setBlockData(other.getBlockData()); } }
public void repair() { if (getWorld().getBlockAt(getX(), getY(), getZ()).getState().getData() instanceof Door) return; Block b = getWorld().getBlockAt(x,y,z); if (b.getType() == Material.AIR) b.setType(Material.STONE); super.repair(); other.getBlock().setBlockData(other.getBlockData()); } }
/** * Checks for double drops * * @param blockState Block being broken */ protected static void checkForDoubleDrop(BlockState blockState) { if (mcMMO.getModManager().isCustomLog(blockState) && mcMMO.getModManager().getBlock(blockState).isDoubleDropEnabled()) { Misc.dropItems(Misc.getBlockCenter(blockState), blockState.getBlock().getDrops()); } else { if (Config.getInstance().getWoodcuttingDoubleDropsEnabled(blockState.getBlockData())) { Misc.dropItems(Misc.getBlockCenter(blockState), blockState.getBlock().getDrops()); } } }