@Override public int getComparatorInputOverride(IBlockState blockState, World world, BlockPos pos) { return MathHelper.floor_float(getRettingPercent(world, pos) * MiscHelper.MAX_REDSTONE_SIGNAL_STRENGTH); }
public int getComparatorSignalStrength() { if (isComposting()) return Math.max(0, MathHelper.floor_float(getCompostTemperature() / MAX_COMPOST_TEMPERATURE * MiscHelper.MAX_REDSTONE_SIGNAL_STRENGTH)); else return 0; }
/** * Returns a point that the entity can safely move to */ private PathPoint getSafePoint(Entity entityIn, int x, int y, int z) { BlockPos pos = new BlockPos(x, y, z); entitySizeX = MathHelper.floor_float(entityIn.width + 1); entitySizeY = MathHelper.floor_float(entityIn.height + 1); entitySizeZ = MathHelper.floor_float(entityIn.width + 1); for (int ix = 0; ix < entitySizeX; ++ix) { for (int iy = 0; iy < entitySizeY; ++iy) { for (int iz = 0; iz < entitySizeZ; ++iz) { IBlockState blockState = blockaccess.getBlockState(pos.add(ix, iy, iz)); if (blockState.getMaterial() != Material.AIR) { return null; } } } } return openPoint(x, y, z); } }
/** Returns if the entity is covered in enough water * @param entity the entity * @return if it's considered as in water */ public static boolean isInWater(Entity entity) { double eyes = entity.posY + (double)entity.getEyeHeight() - 0.65; int i = MathHelper.floor_double(entity.posX); int j = MathHelper.floor_float(MathHelper.floor_double(eyes)); int k = MathHelper.floor_double(entity.posZ); BlockPos pos = new BlockPos(i, j, k); IBlockState state = entity.worldObj.getBlockState(pos); Block block = state.getBlock(); if (state.getMaterial() == Material.WATER) { double filled = 1.0f; //If it's not a liquid assume it's a solid block if (block instanceof IFluidBlock) { filled = ((IFluidBlock)block).getFilledPercentage(entity.worldObj, pos); } else if (block instanceof BlockLiquid) { filled = BlockLiquid.getLiquidHeightPercent(block.getMetaFromState(state)); } if (filled < 0) { filled *= -1; return eyes > pos.getY() + 1 + (1 - filled); } else { return eyes < pos.getY() + 1 + filled; } } else return false; }